• I am running Display Suite 7.x-2.8 which I know is older, but the relevant portion of the ds_extras_node_page_view() function has not changed between versions 7.x-2.8 and 7.x-2.14.
  • My site is multilingual (i18n) - not sure if it matters.
  • I am also using the Global Redirect module, but it has issues of its own when it comes to i18n and front page redirects. I don't have front page redirects enabled there, and am not having Global Redirect set canonical links.
  • My site's home pages all use Panels and Panelizer, and I have Display Suite Extras enabled as well.

Display Suite Extras comes with a ds_extras_node_page_view() function which spits out a canonical link in the HTML head, overriding Drupal's default behavior from the node module. However, on the front page it was spitting it out with the path to the node, rather than the front page's path. So for example for Czech, it was spitting out "/cz/my-home-page-alias" rather than "/cz".

I wrote a small patch for Display Suite Extras which checks whether the current page is the front page and if so, use that for the canonical link, rather than the node's path. This is working for me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

caspervoogt created an issue. See original summary.

caspervoogt’s picture

and here's the patch

caspervoogt’s picture

caspervoogt’s picture

it's a simple enough patch - have not tested it though. I am just replacing this:

drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);

with this:

drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url(drupal_is_front_page() ? '<front>' : $uri['path'], $uri['options'])), TRUE);

This is the same way that Global Redirects handles the front page canonical link.

caspervoogt’s picture

Issue summary: View changes