Canonical url trailing slash missing for homepage – WordPress & Yoast
When you install WordPress in a sub directory Example: ‘blog’, the canonical link should be: www.example.com/blog/. But Canonical url trailing slash will be missing for homepage. Yoast will show the home page canonical tag, without having a trailing slash like this : www.example.com/blog
All pages will show the canonical URLs as having a trailing slash except the home page. Yoast WordPress SEO plugin gives canonical url and sitemap url as www.example.com/blog which is incorrect. So the problem is, Google will index home page (www.example.com/blog/) without a trailing slash. The SEO plugin should put the trailing slash in the canonical url and in the sitemap when the site is in a subdirectory.
Solution:
There is no need for editing .htaccess file. You can fix this issiue from WordPress admin panel.
Wordpress admin panel -> Plugins -> Editor. Select WordPress SEO from the right top of the page. Find and select the file “wordpress-seo/frontend/class-frontend.php” from the right side of files list.
In that file, find this code: ” $canonical = home_url(); ”
Update that code like this : ” $canonical = home_url(‘/’); ”
Done !!
Canonical url trailing slash will be showing for home page (www.example.com/blog/)
- Top 10 Features in Angular 18 You Need to Know - June 25, 2024
- Specialities of Kerala’s agricultural and religious festival Vishu - November 25, 2022
- Why Kerala is known as God’s own country – Part 2 - June 20, 2019