To reproduce: start with a clean D8 beta3 install,

  • Enable the Configuration translation and Language modules.
  • Enable 3 languages - I picked English, Swedish and Arabic
  • Don't enable any language detection methods. Ideally the interface should provide the option to simply match the node body content but that option is sadly missing and a separate issue..
  • In the Content language settings make "Content" translatable and tick all boxes under article and basic page.
  • Now create an article in english and give it a unique alias. Mine was titled "Drupal is the best thing since sliced bread". With the url alias "breaden"
  • Use the translate tab to make 2 translations of this into swedish and arabic and give them aliases "breadsv" and "breadar"

Everything looks like it should be fine but only the english version is reachable. The links to breadsv and breadar in the english page header below give 404 not found errors:

<link rel="alternate" hreflang="en" href="http://hub:8089/breaden" />
<link rel="alternate" hreflang="sv" href="http://hub:8089/breadsv" />
<link rel="alternate" hreflang="ar" href="http://hub:8089/breadar" />

The bug is that these alternate links in the page head are correct, but could be better.., and should work but don't.

The alternate link to the english version shouldn't be there at all by the way. These links should really have titles and be part of the http headers as well.

I have a similar situation in d7 that I work around with code in the theme template.
https://www.drupal.org/node/2382467

Comments

iliphil’s picture

Issue summary: View changes
iliphil’s picture

Issue summary: View changes
iliphil’s picture

Priority: Normal » Major
catch’s picture

Version: 8.0.0-beta3 » 8.0.x-dev
Issue tags: +D8MI
djevans’s picture

I've tried to reproduce this on 8.0.x-dev (see attached test case).

  • Enable the following modules with the Standard install profile:
    • Content translation (not Configuration translation)
    • Language
    • Path
  • Add two languages (here, Welsh and Japanese)
  • Create an 'article' content type and make it translatable
  • Create an article in English, and then add two translations

The links in the page header appear like this:

<link rel="alternate" hreflang="en" href="http://local.dev/bread">
<link rel="alternate" hreflang="cy" href="http://local.dev/cy/bara">
<link rel="alternate" hreflang="ja" href="http://local.dev/ja/pan">

Regarding the links themselves, according to Google (Use hreflang for language and regional URLs):

If you have multiple language versions of a URL, each language page must identify all language versions, including itself.  For example, if your site provides content in French, English, and Spanish, the Spanish version must include a rel="alternate" hreflang="x" link for itself in addition to links to the French and English versions. Similarly, the English and French versions must each include the same references to the French, English, and Spanish versions.

So it looks like we shouldn't get rid of the link for the current language.

djevans’s picture

StatusFileSize
new5.73 KB

Trying again with an actual patch. :)

legolasbo’s picture

Status: Active » Needs review

Let's set this to needs review so testbot can have a look at the patch.

iliphil’s picture

DJevans is right about the links - the link for the current language should stay. What the test patch is not doing is removing the default interface language detection so my original description of the bug should read "disable" rather than "don't enable". The use case for doing this is simply that when migrating existing translated content to Drupal then you should be able to use your existing urls rather than being forced into a url scheme with the language and the locale in the url. The inferface appears to let me do this - in the "Detection and selection" I can uncheck the boxes (except for the last one - Language based on a selected language)and create translations with arbitrary urls but the translations are unreachable.

Here it is not working (b15):

http://drupaldev.independentliving.org/bread

the html header from that page:

<link rel="alternate" hreflang="en" href="http://drupaldev.independentliving.org/bread" />
<link rel="alternate" hreflang="sv" href="http://drupaldev.independentliving.org/brod" />
<link rel="alternate" hreflang="es" href="http://drupaldev.independentliving.org/pan" />

http://drupaldev.independentliving.org/brod
Page not found
The requested page could not be found.

http://drupaldev.independentliving.org/pan
Page not found
The requested page could not be found.

legolasbo’s picture

@Iliphil,

Could you provide the steps to reproduce this on a vanilla installation of head?

iliphil’s picture

The steps are essentially the same as djevans described with one additional step

  1. Enable the following modules with the Standard install profile:
    • Content translation
    • Language
    • Path
  2. Add two languages
  3. Disable all interface language detection methods
  4. Create an 'article' content type and make it translatable
  5. Create an article in English, and then add two translations

The page head will then look like this, but only one of the links will work - the other two will be 404s.

<link rel="alternate" hreflang="en" href="http://drupaldev.independentliving.org/bread" />
<link rel="alternate" hreflang="sv" href="http://drupaldev.independentliving.org/brod" />
<link rel="alternate" hreflang="es" href="http://drupaldev.independentliving.org/pan" />
plach’s picture

Priority: Major » Normal

If this concerns only alternate href links then it does not look major...

plach’s picture

Component: language system » content_translation.module

Also, the test-only patch is not failing so this clearly needs work :)

plach’s picture

Status: Needs review » Needs work

me--

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

raphaeltbm’s picture

Status: Needs work » Closed (outdated)

I doesn't seems to be related to the alternate links in the head if it's a problem of URL access. I close it because, not reproducible and pretty outdated now. Feel free to open again if needed.