If a page's langcode is LANGUAGE_NONE it may be useful if the hreflang meta tags could be output for all locales. This would help with e.g. the front page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna created an issue. See original summary.

DamienMcKenna’s picture

Issue summary: View changes
DamienMcKenna’s picture

We'd need to add new tokens for this, it could get messy.

jantoine’s picture

Status: Active » Needs review
FileSize
2.71 KB

Here's a first stab at this. I'm not sure if we need to worry about the default behavior changing?

With the site default language set to example.com.au and a second custom locale of example.co.nz added, here are various outputs:

  • Homepage with global overrides.
    • .com.au
      <link rel="alternate" hreflang="x-default" href="https://www.example.com.au/">
      <link rel="alternate" hreflang="en_nz" href="https://www.example.co.nz/">
              
    • .co.nz
      <link rel="alternate" hreflang="x-default" href="https://www.example.com.au/">
      <link rel="alternate" hreflang="en_nz" href="https://www.example.co.nz/">
              
  • Language Neutral Node
    • .com.au
      <link rel="alternate" hreflang="x-default" href="http://dev.d7.example.com.au/language-neutral">
      <link rel="alternate" hreflang="en_nz" href="http://dev.d7.example.co.nz/language-neutral">
              
    • .co.nz
      <link rel="alternate" hreflang="x-default" href="http://dev.d7.examplem.au/get-started">
      <link rel="alternate" hreflang="en_nz" href="http://dev.d7.example.nz/get-started">
              
  • Node with translations for both languages and different path aliases
    • .com.au
      <link rel="alternate" hreflang="x-default" href="http://dev.d7.examplem.au/australian">
      <link rel="alternate" hreflang="en_nz" href="http://dev.d7.example.nz/newzealand">
              
    • .co.nz
      <link rel="alternate" hreflang="x-default" href="http://dev.d7.jennycraig.com.au/australian">
      <link rel="alternate" hreflang="en_nz" href="http://dev.d7.jennycraig.co.nz/newzealand">
              
  • Node with .com.au only
    <link rel="alternate" hreflang="x-default" href="http://dev.d7.jennycraig.com.au/australian-only">
        
  • Node with .co.nz only
    <link rel="alternate" hreflang="x-default" href="http://dev.d7.jennycraig.co.nz/newzealand-only">
        

I'm not sure if the tag should exist at all on pages with a single translation, but I wasn't sure if it mattered either way.

mstrelan’s picture

Status: Needs review » Needs work

Patch needs a re-roll.