How to create SEO friendly sluggable URL
2 minutes ago
In this post, I am going to share with you How to generate SEO friendly URL in Laravel 5 application.
SEO is very important part of website for increase users traffic. If your website have seo friendly URL then it can help to increase your site rand in google index, yahoo etc. So If you require to generate SEO friendly URL in your laravel application then We can do it by “eloquent-sluggable” package. eloquent-sluggable package developed by cviebrock.
Eloquent-sluggable package provide to automatic create unique url for our post. this package create unique slug url that way it is good for SEO.
You can do it for your laravel application by following step or if you want to do it from scratch then you can get fresh laravel by following step 1. After finish this example you will get bellow output.
Step 1: Install Laravel 5.3 Application
In this step, if you haven’t laravel 5.3 application setup then we have to get fresh laravel 5.3 application. So run bellow command and get clean fresh laravel 5.3 application.
composer create-project --prefer-dist laravel/laravel blog
Step 2: Install Package
In this step we have to add eloquent-sluggable package for generate unique slug url so one your cmd or terminal and fire bellow command:
composer require cviebrock/eloquent-sluggable
After successfully install package, open config/app.php file and add service provider and alias.
'providers' => [ .... Cviebrock\EloquentSluggable\ServiceProvider::class, ] .....
You can publish the default configuration file by following command:
php artisan vendor:publish --provider="Cviebrock\EloquentSluggable\ServiceProvider"
Step 3: Create Item Table and Model
Originally published at laravelfeed.com.