By jhun vert on
The source file shows the following lines
<link rel="canonical" href="/example-article" />
<link rel="canonical" href="http://www.example.com/example-article" />
<link rel="shortlink" href="/node/1" />The absolute link is created by the Global Redirect module. The relative one, I guess is a default of Drupal 7 (I am not not sure about this). Google said they recommend absolute links to minimize potential confusion or difficulties.
How can I take off that relative URL?
Comments
Subscribe
Subscribe
Contact me to contract me for D7 -> D10/11 migrations.
Canonical Links
Hi,
I spent too many hours putting together this solution for canonical links and Drupal 7 so i am glad to share this. It has been an amalgamation of a few different sources of code, however i don't remember where so I'm sorry no references...
What i wanted to do was remove, the canonical, shortlink and generator tags. Remove the first unset line and second If statement if you don't want to remove them as well.
To start with I untick the Add Canonical in Global Redirect. Then just add your themename at the top of the function, replace your preferred base url by the $can_link variable depending on what you have setup in Google Analytics or your .htaccess file. Then copy all the code and add it to your template.php file.
Happy to hear any suggestions to improve on this but it works!
Thanks
Thanks for the above
Thanks for the above solution.
Here was my problem: In the html source code, the meta tags were added only once:
Perfect actually.
However, the http header that was sent actually displays the link variable multiple times, so checking my http header on http://network-tools.com gave me the following:
As you can see, I have the Link element a lot of times in there and I have no idea where this is coming from - it only happens on the front page.
So I used the above solution to remove all link tags and re-add the canonical link, but how do you go about adding the shortlink as well?