Blogging is a great way to share your thoughts and ideas with the world. But if you want people to be able to find your blog, you need to make sure that your blog’s URL is easy to remember and easy to find. That’s where URL slugs come in. A URL slug is simply the part of the URL that comes after the domain name.
For example, in the URL “www.example.com/blog/this-is-a-blog-post”, the slug is “this-is-a-blog-post”. The slug helps people to remember and find the specific blog post that they’re looking for. And it helps search engines to index your blog posts so that people can find them more easily.
CodeIgniter’s built-in URL Helper library offers a quick and easy way to convert your blog titles into URL slugs. url_title is a handy lib that makes it easy to format URLs quickly and easily. With just a simple string input, this handy tool will automatically generate a URL-formatted string, complete with word separators and lowercase characters as necessary.
//syntax url_title($str, $separator = '-', $lowercase = FALSE)
|Parameters:||$str (string) – Input string|
$separator (string) – Word separator
$lowercase (bool) – Whether to transform the output string to lower-case
$title = "CodeIgniter Can Be Used to Make a Blog Platform"; $url_title = url_title($title, '-', true); //output: codeigniter-can-be-used-to-make-a-blog-platform