Convert multiline text to slug, Bulk slug generator using jQuery

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.

<textarea id="txt_src" rows="10">our multi-line text, strings, will paste here</textarea>

Second textarea will display Slugify url after clicking on generate button.

<textarea id="txt_trg" rows="10"></textarea>

Button to perform action on click.

<button id="slug">Generate Slug</button>



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.

DEMO | DOWNLOAD

This awesome jQuery plugin is developed by atakanau. Visit their official github repository for more information and follow for future updates.


One Reply to “Convert multiline text to slug, Bulk slug generator using jQuery”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.