Canonical URL tag in a page prevents the same page from indexing twice or more for better search engine optimization. For example, if you have URLs for the same page (for example: example.com?dress=1234 and example.com/dresses/1234 ), Google chooses one as canonical.
To enable or disable it in your WordPress website, posts, and pages you can do this simple editing. There is a WordPress inbuilt function you can prevent it by adding this to your theme´s functions.php
remove_action('wp_head', 'rel_canonical');
It is already enabled by default on WordPress and themes, but if it is not showing in your websites then remove or comment the above line of code in functions.php file of your theme.
I commented this line today for one of my local clients WordPress blog site. The code was present in funtions.php file of a child theme currently in use. After commenting canonical tag appeared on all pages (checked via chrome view source or “ctrl + u” key press ) and also on AMP pages.
Screenshot of google search console showing AMP pages not having mandatory canonical URL tag.
You must be logged in to post a comment.