Everyone that knows me will know that I hate using WordPress plugins, not that Iâ€™m a website designer that believes that every other designer and coder should write their own code, far from it. Iâ€™m a web designer that believes you should only use trusted plugins when you absolutely need to. Using a plugin that offers you 100 features when you only need one, makes no sense to me! Using such a plugin is only going to bloat your code, slow down your SQL and increase the chances of exploitable vulnerabilities.
Whenever possible you should avoid using WP plugins unless you absolutely need to, if youâ€™re looking to use just canonical URLS then you donâ€™t need a fancy all dancing all singing SEO plugin, you can add canonical URLS to WordPress without a plugin, in fact in this short guide Iâ€™ll provide you the code that with work with any content management system that uses PHP.
WordPress SEO Plugins
I do however recommend Yoast SEO or any other reputable SEO plugin if you want better SEO management, such as changing titles and meta descriptions but only if you need thisâ€¦ a 5 page business website doesnâ€™t really require an SEO plugin because everything you can do with the plugin you can do without, of course it might take you 20mins more! But the end results will be a site that is easier to upgrade without fear of something going wrong and a cleaner SQL database.
Universal PHP Code for Canonical URLS
Below is the code that you need to add within the head of your theme template:
<link rel="canonical" href="https://www.bybe.net<?php echo $_SERVER['REQUEST_URI'];?>">
Obviously you will need to replace bybe.net with your own domain.
Adding canonical Links in WordPress
Below are a few easy steps that will have you up and running with WordPress canonical URLS in no time at all, and without a plugin.
- Login to WordPress
- Hover over Appearance
- Click Editor
- Find Theme Header (header.php)
- Add the Universal PHP Code for Canonical URLS found above within the HEAD section of your theme header file.