How to create canonical tag in laravel website?

How to create canonical tag in laravel website? Creating a canonical tag in a Laravel website involves adding a <link> tag to the <head> section of your layout file. The rel attribute of the tag should be set to “canonical”, and the href attribute should be set to the URL of the page you want to specify as the canonical version. Here is an example of how to add a canonical tag to a Laravel website: <head> <link rel=”canonical” href=”{{ url()->current() }}” /> </head> This code will add a canonical tag to every page in your Laravel website. If you want to add the canonical tag to only specific pages, you can use an if statement to check the current URL. Here is an example of how to add a canonical tag to only the homepage of your Laravel website: <head> @if (url()->current() === url(‘/’)) <link rel=”canonical” href=”{{ url(‘/’) }}” /> @endif </head> You can then use the canonicalUrl() helper function to add the canonical tag to your layout file: <head> <link rel=”canonical” href=”{{ canonicalUrl(request()) }}” /> </head> This code will add a canonical tag to every page in your Laravel website, and the canonical URL will be generated based on the current URL. #Laravel #SEO #HTML #tag #canonical Amir Rizvandi

Read More