Creating slugs for domain names is a great way to turn common phrases in to searchable SEO friendly domain names. You can try multiple methods of using plain text to generate URL friendly domain names and permalinks. Slugifying is a common practice to get a short, unique, web friendly word from a phrase or name. WordPress slug URLs are used within WordPress to create unique permalink URLs for each post and page. So if you want to add this type of feature to automatically generate your normal text into SEO url friendly link then here I am going to share simple jQuery plugin which help you to generate burl slug url.
Libraries
Include the following libraries on page.
<script src="//code.jquery.com/jquery-latest.min.js">script> <script src="url_slug.js">script> |
HTML
Create a textarea where your’ll write or paste text, string.
> |
Second textarea will display Slugify url after clicking on generate button.
Button to perform action on click.
<button id="slug">Generate Slug> |
JS
Call the function on page and convert normal text into Slugify seo friendly URL.
jQuery(function($){ $('#slug').click(function(){ var lines = $('#txt_trg').val(""); var lines = $('#txt_src').val(); var lines_array = lines.split("\n"); for(i=0;i<lines_array.length;i++){ $('#txt_trg').val( $('#txt_trg').val() + url_slug(lines_array[i]) + "\n")// getSlug(lines_array[i]); } }); }); |
See live demo and download source code.
This awesome jQuery plugin is developed by atakanau. Visit their official github repository for more information and follow for future updates.