Canonical for dynamic pages in CodeIgniter
In this blog, we will learn how to use canonical for dynamic pages in Codeigniter. Canonical is an important part of SEO, It is used to prevent URL duplicity. It tells the search engine this page has a particular URL.
Let’s see how we use canonical in CodeIgniter, paste this code in the head section of your page:
<?php
echo '<link rel="canonical" href="' . site_url( $this->uri->uri_string() ) . '" />' ?>
Example:
<head>
<?php
echo '<link rel="canonical" href="' . site_url( $this->uri->uri_string() ) . '" />' ?>
</head>
Why should we use canonical in our page?
Duplicate URL or content is very harmful to our website, when search engines crawl our website pages if we don’t use canonical it crawl our single page multiple times and treat it as duplicate. If a search engine finds duplicate content it give a bad impact on our website ranking.
So keep in mind canonical is necessary for making our website search engine friendly.