Bug from https://www.drupal.org/node/2303525
As described in the description of the ticket as well as in the description of the page that is linked off to in the ticket that google (https://support.google.com/webmasters/answer/189077) has written up this tag needs to be in the head of the page.
The implementation that currently sits in core only adds these tags to the language switcher and not into the head of the html page.
Updates on reproducing issue as mentioned by #3. 2020/06/17
Once the language and content translation modules are enabled and configured, all entities (term, contents) created will have hreflang tag in head of html whether it is translated or not. Yet the default homepage (/node) doesn't apply.
There is an improvement issue filed for Improve the alternate hreflang implementation
https://www.drupal.org/project/drupal/issues/2994800.
steps to reproduce
1. install Drupal 9.1.dev with default language
(no hreflang tag in head of default homepage)
2. create new entity node of any content type (e.g. articles, /node/1)
(no hreflang tag in head of entity)
3. enable module language and content_translation, activate new language in /admin/config/regional/language and allow content types translation in /admin/config/regional/content-language.
4. Translate node/1 to chosen language.
(hreflang tag appears on both entity head, e.g. /node/1 & /zh-hant/node/1)
5. If default front page is set as "/node", expect no hreflang tag shown in head unless set default frontpage to other entity pages like "/node/1".
Default frontpage & HTML
Entity pages & HTML
Comment | File | Size | Author |
---|---|---|---|
#21 | Screenshot 2021-10-04 at 5.33.09 PM.png | 551.04 KB | madhu_h |
#21 | Screenshot 2021-10-04 at 5.31.26 PM.png | 677.64 KB | madhu_h |
#16 | hreflang_tag_entity_page_setfront.png | 22.28 KB | g-brodiei |
#16 | hreflang_tag_entity_page.png | 12.04 KB | g-brodiei |
#16 | hreflang_tag_default_html.png | 32.01 KB | g-brodiei |
Comments
Comment #1
lathanComment #2
pdenooijer CreditAttribution: pdenooijer commentedThis is already fixed in the bug report mentioned at the start of the bug report, https://www.drupal.org/node/2303525.
I tested it on the current (25-June-2015) 8.0.x branch of drupal and I can confirm that there is a hreflang tag in the HTML head. See the screenshot for conformation.
Comment #3
lathanRight so i have figured out what the issue is, the front page if it is not a instance of a drupal entity does not get this hreflang tag, this is probably the most beneficial page to have this specific tag as it has quite an impact on SEO.
The second issue is that when a node has been translated into different languages. This current patch assumes that both languages are published, we then start seeing 404's in google crawl report.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedThis needs an IS update, and I'm wondering as per #3 whether or not we need to split this up in two separate tickets.
Comment #5
swentel CreditAttribution: swentel commented#2521782: HTML head has alternate hreflang links to unpublished translations exists for the 404 (or rather 403)
As for the front page, that is a view, which as far as I know not translatable by default, so I'm not sure there's a bug here.
Comment #6
catchComment #16
g-brodieiUpdated the issue summary + steps to reproduce.
Add parent issue "improvement in alternate hreflang tag".
https://www.drupal.org/project/drupal/issues/2994800
Comment #18
g-brodieiJust found out that as #5 mentioned, it is expected as hreflang tag not displaying on views pages, even if the configurations are translated. On the other hand, translated entities have hreflang tag in head. Which was commited in https://www.drupal.org/project/drupal/issues/2303525.
I guess the issue should be that we need an improvement on addressing hreflang tag on other non-entity based pages like @mfb said.
https://www.drupal.org/project/drupal/issues/2303525#comment-9368051
I'll suggest this issue to be closed.
Comment #21
madhu_h CreditAttribution: madhu_h at Acquia for Acquia commentedVerified and tested.
Testing Steps:
1. install Drupal 9.1.dev with default language (no hreflang tag in head of default homepage)
2. create new entity node of any content type (e.g. articles, /node/1) (no hreflang tag in head of entity)
3. enable module language and content_translation, activate new language in /admin/config/regional/language and allow content types translation in /admin/config/regional/content-language.
4. Translate node/1 to chosen language. (hreflang tag appears on both entity head, e.g. /node/1 & /zh-hant/node/1)
5. If default front page is set as "/node", expect no hreflang tag shown in head unless set default frontpage to other entity pages like "/node/1".
Test Results:
- When we visit entity pages, hreflang tag is appearing in head
https://www.drupal.org/files/issues/2021-10-04/Screenshot%202021-10-04%2...
- However in case of view pages,hreflang tag is not appearing in head
https://www.drupal.org/files/issues/2021-10-04/Screenshot%202021-10-04%2...
Test Status: NEEDS REVIEW
Comment #25
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Tagging for issue summary update with what the proposed solution should be.
As noted in #18
So what is the desired behavior here?
Comment #26
smustgrave CreditAttribution: smustgrave at Mobomo commentedAlso meant to tag for accessibility if they can offer guidance
Comment #27
mfbI'm not sure as I didn't file this issue, but I think it's a feature request for core to generate hreflang tags on pages that are not translated entities. Or it could also be thought of as a bug report on the existing feature, where core generates hreflang tags only for translated entity pages.
On a typical multilingual site, other kinds of pages (e.g. the default front page, /node, which is a view page) can be accessed in different languages - which would show some mix of translated user interface and/or translated content - and for SEO purposes you'd want to have hreflang tags on these pages.
At the moment this feature is provided by contrib Hreflang module, which has ~12,500 installs on drupal 7 thru 10, so seems potentially useful enough to be part of core, but *shrug* could also be won't fixed if core is not interested.
Comment #28
smustgrave CreditAttribution: smustgrave at Mobomo commentedSeems like it wouldn’t be terrible to fold that in but don’t know the process for that
Comment #29
mfbAdding #3226887: Hreflang on non-canonical content pages as a related issue as it has to do with hreflang. (Tl;dr: There's an assumption that hreflang and other meta tags can be built up in the #attached array where they will be automatically de-duplicated and other modules can alter them. But in fact, the hreflang tags should change depending on the query arguments on the page, and so I think they should be using a placeholder that gets swapped out at the last minute via a lazy builder. Although this change would be a BC break.)
Comment #30
catchIf it's just changing something in a render array, that's fine with a change record / release notes mention in a minor release.
I can't see a patch here, so switching the status to 'active', this seems reasonable to add but I don't think it's a bug as such (and the contrib module can be used in the meantime), so moving to 'task'.