Wordpress canonical URL without plugin?

Jack London

New member
Joined
Jul 9, 2012
Messages
386
Points
0
I understand how to use canonical urls on a static HTML based site, but I don't understand where to include these URLs on a WordPress based site. I researched and found a few plugins to do this but it it possible for me to only have access to the files of my theme? so I'm a bit lost as to how to access the head tags for those URLs to input the code. Can you guys shoot me a guide?
 

Netman82

New member
Joined
Feb 2, 2018
Messages
8
Points
0
<link rel="canonical" href="https://mysiteurlDOTcom<?php echo $_SERVER['REQUEST_URI'];?>">

1. Login to WordPress
2. Hover over Appearance
3. Click Editor
3. Find Theme Header (header.php)
5. Add the Universal PHP Code for Canonical URLs found above within the HEAD section of your theme header file.
 

vishwa

Well-known member
Joined
May 12, 2014
Messages
1,144
Points
63
I think that we all need an SEO plugin for our WordPress blog. Hence most of the SEO plugin comes with features like Canonical URL. Adding it manually to theme header file can be risky as when you update your theme files it will be removed and you have to put it again. You can use Yoast SEO plugin. Works great for me.
 

copperman

New member
Joined
Jul 6, 2019
Messages
23
Points
3
I have been using the Yoast plugin.

All the pages have the Canonical URLs except for the homepage.

Is there a code that adds a Canonical URL only on the homepage?

I tried this <link rel="canonical" href="https://mysiteurlDOTcom<?php echo $_SERVER['REQUEST_URI'];?>"> works really well. Thank you, Netman82

But it doubles the Canonical URLs on the other pages, as Yoast already adds it on the other pages.

Thank you.
 
Latest threads
Replies
0
Views
589
Replies
2
Views
788
Replies
1
Views
309
Recommended threads
Replies
1
Views
3,530
Replies
14
Views
4,174
Replies
27
Views
18,393

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top