laravel seo package step by step installation guide 2021

    By: Manu
    2 years ago

    Hi there, Welcome to this post. So we are going to setup SEO for our website. So first of all this package that we are going to install today will allow you to add meta tags for your website. Meta tags are important as search engines look for meta tags. Search engine like google, yahoo, bing etc. So let's begin installing SEO in laravel.

    Step 1: Install SEO Package.

    Install the package in your project folder using below given command.

    composer require davmixcool/laravel-meta-manager

    It should look like this if all goes as planned.

    Once you installed it. Next step is to

    Step 2:  Include the service provider

    Yeh we need to add service provider. So in your project go to "config/app.php". and add Provider in

    'providers' => [
            Davmixcool\MetaManager\MetaServiceProvider::class,
    ];

    Yeh simply add under "providers" array. Now it is time to run another command.

    php artisan vendor:publish --provider="Davmixcool\MetaManager\MetaServiceProvider"

    Running above given command will add a file under "Config" folder. With the name of "meta.php". Meta.php file should have below given fields to fill.

    
    return [
    	/*
        |--------------------------------------------------------------------------
        | Robots
        |--------------------------------------------------------------------------
        |
        | Robots option tells search engines what to follow and what not to follow.
        | It's a simple option that gives you the power to decide about what
        | pages you want to hide from search engine crawlers and what pages you
        | want them to index and look at.
        |
        */
    	'robots' => 'all',
    
    
    	/*
        |--------------------------------------------------------------------------
        | Revisit After
        |--------------------------------------------------------------------------
        |
        | Here you may specify how search engines will re-visit and re-crawl your site.
        |
        */
    	'revisit_after' => 'period',
    
    
    	/*
        |--------------------------------------------------------------------------
        | Referrer
        |--------------------------------------------------------------------------
        |
        | Here you may specify how you want other sites to get referrer information
        | from your site.
        | options available are: none, unsafe-url, origin and none-when-downgrade
        |
        */
    	'referrer' => 'no-referrer-when-downgrade',
    
    
    	/*
        |--------------------------------------------------------------------------
        | Type
        |--------------------------------------------------------------------------
        |
        | Here you may specify the structure type of your website or a specific page
        |
        */
    	'type' => 'website',
    
    
    	/*
        |--------------------------------------------------------------------------
        | Title
        |--------------------------------------------------------------------------
        |
        | Here you may provide the title of your website or a specific page to help search
        | engines understand it better.
        |
        */
    	'title'	=> ' ',
    
    	/*
        |--------------------------------------------------------------------------
        | Description
        |--------------------------------------------------------------------------
        |
        | Here you may provide the description of your website or a specific page to
        | help search engines understand it better.
        |
        */
    	'description' => '',
    
    	/*
        |--------------------------------------------------------------------------
        | Image
        |--------------------------------------------------------------------------
        |
        | Here you may provide the url to the image you want search
        | engines and crawlers to make use of when displaying your website
        | or a specific page page.
        |
        */
    	'image' => '',
    
    	/*
        |--------------------------------------------------------------------------
        | Author
        |--------------------------------------------------------------------------
        |
        | Here you may provide the author's name you want search
        | engines to make use of when displaying your website
        | or a specific page page.
        |
        */
    	'author' => '',
    
    
    	/*
        |--------------------------------------------------------------------------
        | GEO REGION AND POSITION
        |--------------------------------------------------------------------------
        |
        | These are for use if you have a physical location that is important
        | for your business.
        |
        */
    	'geo_region' => '', //e.g: Lagos
    	'geo_position' => '', //e.g(lng,lat): 4.870467,6.993388
    
    
    	/*
        |--------------------------------------------------------------------------
        | TWITTER SITE
        |--------------------------------------------------------------------------
        |
        | Here you may provide your twitter @username of your account
        |
        */
    	'twitter_site' => '',
    
    	/*
        |--------------------------------------------------------------------------
        | TWITTER SITE
        |--------------------------------------------------------------------------
        |
        | Here you may specify the way you want crawlers to understand your
        | twitter share type. Check twitter docs for more options.
        |
        */
    	'twitter_card' => '',
    
    
    	/*
        |--------------------------------------------------------------------------
        | FACEBOOK APP ID
        |--------------------------------------------------------------------------
        |
        | Here you may provide your facebook app id
        |
        */
    	'fb_app_id' => '',
    
    
    
    	/*
        |--------------------------------------------------------------------------
        | KEYWORDS
        |--------------------------------------------------------------------------
        |
        | Here you may provide keywords relevant to your website and the specific page.
        |
        */
    	'keywords' => ''
    
    
    ];
    

    Add values in the blank spaces for examples title, description, keywords etc.

    Now we have setup the keywords and tags we need to include them in pages to do that add below given line in "head" of your application. In Laravel you can add in layout file. Add this

    @include('meta::manager')

    You can check the webpage of SEO Package ( Laravel Meta Manager) for more details. Above given line of code will load all tags and values from "config/meta.php" file. So make sure you have updated the meta values there.

    Step 3: Passing Dynamic Values.

    Now if you want to show values and keywords dynamically page by page. Then you can do that too. In that case pass values like this.

    @include('meta::manager', [
        'title'         => 'My Example Title',
        'description'   => 'This is my example description',
        'image'         => 'Url to the image',
    ])

    Hope this post will be useful please share and like. If you liked our efforts.

    https://www.youtube.com/watch?v=rnFgCr3Q4FM&list=PLbzI0wCtFcqDl1hZLVk0zuQf_JogKTAjV