1

I've not been using Drupal for long (< 3 weeks) but have good knowledge of standard PHP, so I really don't know the 'Drupal' way of doing things yet.

What I'm trying to do is edit the canonical tag for a mobile site. The current path is realtive, however I need it to be absolute, and link to the desktop version of the site.

As far as I can tell the current implementation is not using any module to insert the canonical tag.

By looking at the source code of the rendered page the code appears to be contained in the $head variable which is in html.tpl.php as below

<head profile="<?php print $grddl_profile; ?>">
<?php print $head; ?>
<title><?php print $variables['field_meta_title']; ?></title>

I've come across a couple of pages like this one that mention things like template_process_html, drupal_get_html_head() and hook_html_head_alter() as relevant functions, but in that example the request is to remove the canonical tags, not to edit them.

I wouldn't mind using a module (providing it would allow me to change the link from www.mysite.com... to m.mysite.com...) but I would need to remove the current canonical tags which comes back to my orignial issue of not being able to find where it is.

1

You need the Meta Tags module.

After you activate it, go to /admin/config/search/metatags/config/global and, under advanced, you can change the default canonical link.

Look at the path patterns used for PathAuto and prefix them with the desired base url.

  • I did come across that module, which looks useful, but adding that would then give me 2 canonical links as I'd still be left with the one I can't find, which I presume is a bad idea. – Novocaine Mar 21 '13 at 16:35
  • Drupal does not by itself provide a canonical link. What theme are you using? – Triskelion Mar 21 '13 at 16:50
  • The theme is a custom one. It may or may not have been based on another, I don't know as I've only just started working this site. Could this have been added by the theme then? – Novocaine Mar 22 '13 at 8:42
  • It could have been added by any module calling drupal_add_html_head or theme calling hook_html_head_alter. I would suggest you search your code base for the word "contextual" and see where this is coming from. – Triskelion Mar 22 '13 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.