Problem/Motivation

Default frontpage settings

Hreflang links were pointing to the actual node view page ("node/9") instead of just front ("/") when using that node as a front page (google sent a notification about the issue).

Hreflangs before

Proposed resolution

Don't create hreflang links from the entity route, just add the languages prefix to root path.

Hreflangs after

CommentFileSizeAuthor
#46 problematic_hreflang_links-2796399-46.patch3.19 KBcriz
#43 after.png215.32 KBabhisekmazumdar
#43 before.png167.85 KBabhisekmazumdar
#42 interdiff_34-42.txt843 bytessarvjeetsingh
#42 problematic_hreflang_links-2796399-42.patch3.49 KBsarvjeetsingh
#37 Screen Shot 2020-08-04 at 12.22.10 PM.png137.22 KBKristen Pol
#37 Screen Shot 2020-08-04 at 12.21.47 PM.png134.85 KBKristen Pol
#37 Screen Shot 2020-08-04 at 12.19.58 PM.png151.73 KBKristen Pol
#37 Screen Shot 2020-08-04 at 12.04.43 PM.png166.38 KBKristen Pol
#37 Screen Shot 2020-08-04 at 12.02.28 PM.png96.03 KBKristen Pol
#34 interdiff-32-34.txt773 bytesmayurjadhav
#34 problematic_hreflang_links-2796399-34.patch3.21 KBmayurjadhav
#32 problematic_hreflang_links-2796399-32.patch3.22 KBmayurjadhav
#27 2796399-27.patch3.36 KBKrzysztof Domański
#27 interdiff-24-27.txt779 bytesKrzysztof Domański
#24 default-front-page.JPG25.64 KBKrzysztof Domański
#24 2796399-after.JPG15.37 KBKrzysztof Domański
#24 2796399-before.JPG17.08 KBKrzysztof Domański
#24 interdiff-19-24.txt2.53 KBKrzysztof Domański
#24 2796399-24.patch3.35 KBKrzysztof Domański
#24 2796399-test-only.patch1.61 KBKrzysztof Domański
#19 interdiff_10_19.txt3.22 KBUser Advocate
#19 drupal-hreflang_front_page-2796399-19.patch1.74 KBUser Advocate
#14 drupal-hreflang_front_page-2796399-13.patch2.2 KBpritish.kumar
#12 interdiff.txt1.07 KBpritish.kumar
#12 drupal-hreflang_front_page-2796399-12.patch2.2 KBpritish.kumar
#10 drupal-hreflang_front_page-2796399-10.patch1.97 KBheikki
#6 drupal-hreflang_front_page-2796399-11830798.patch1.64 KBcaspervoogt
#2 hreflang_front_page-2796399-2.patch1.8 KBheikki
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heikki created an issue. See original summary.

heikki’s picture

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.

caspervoogt’s picture

I tested the patch ant it works great for me.

caspervoogt’s picture

Actually, I noticed one problem. It's spitting out https:// for me, rather than http:// which is my current request protocol. My site has no SSL on it, though a shared SSL certificate is available. I have written a patch that can be applied after hreflang_front_page-2796399-2.patch (from #2) to adjust the logic. I have not tested this on an https site, but it works for my http site, in any case. Maybe someone can test it on SSL?

If this works, we can reroll so it can be applied cleanly with a single patch.

caspervoogt’s picture

Status: Needs review » Needs work

The last submitted patch, 6: drupal-hreflang_front_page-2796399-11830798.patch, failed testing.

caspervoogt’s picture

My patch failed testing but it is no surprise since mine was a follow to the initial patch. We'll need to re-roll later.

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.

heikki’s picture

Rerolled the patch for 8.3.x and used caspervoogts way of determining the protocol.

heikki’s picture

Status: Needs work » Needs review
pritish.kumar’s picture

I have uploaded the patch by improving the coding standard issues. I hope it's correct

Status: Needs review » Needs work

The last submitted patch, 12: drupal-hreflang_front_page-2796399-12.patch, failed testing. View results

pritish.kumar’s picture

Status: Needs work » Needs review
FileSize
2.2 KB

Status: Needs review » Needs work

The last submitted patch, 14: drupal-hreflang_front_page-2796399-13.patch, failed testing. View results

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.

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

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

User Advocate’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Needs work » Needs review
FileSize
1.74 KB
3.22 KB

Re-rolling #10 which is the last working patch. I've made the adjustments that were intended in #12 and #14 and done a bit of cleanup.
With regard to the adjustments made in #10 for determining the protocol, I've removed that. Based on my local tests that appears to have been taken care of elsewhere in core but unfortunately I can't say exactly where. This patch applies to 8.7.x and 8.6.x.

Also, this related issue presents a wider perspective and could lead to a different solution to the problem: https://www.drupal.org/project/drupal/issues/2994800

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

botanic_spark’s picture

Patch #19 worked for me. AFAIC this is RTBC.
But given the related issue, I wonder if I should change the status or not.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Piotr Pakulski’s picture

Patch #19 worked for me on 8.8.x.
botanic_spark I would go with this and merge it?

Krzysztof Domański’s picture

The last submitted patch, 24: 2796399-test-only.patch, failed testing. View results

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Krzysztof Domański’s picture

pratik_kamble’s picture

Assigned: Unassigned » pratik_kamble
Krzysztof Domański’s picture

Assigned: pratik_kamble » Unassigned

Needs review.

Krzysztof Domański’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs a re-roll.

mayurjadhav’s picture

Assigned: Unassigned » mayurjadhav

Working on it, Assigning this to me.

mayurjadhav’s picture

Assigned: mayurjadhav » Unassigned
Status: Needs work » Needs review
FileSize
3.22 KB

Rerolled #27 patch, Kindly review.

Kristen Pol’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

Thanks for the update. Tiny nitpick:

+++ b/core/modules/content_translation/content_translation.module
@@ -682,10 +683,21 @@ function content_translation_page_attachments(&$page) {
+          // If the current page is front page, do not create hreflang links
+          // from the entity route, just add the available languages to root path.

Exceeds 80 chars. Consider rewording so it doesn't spill to 3 lines, e.g.

// If the current page is the front page, do not create hreflang links
// from the entity route, just add the languages to the root path.

(You should confirm that fits within the 80 chars because a "the" was added to the first line.)

mayurjadhav’s picture

Status: Needs work » Needs review
FileSize
3.21 KB
773 bytes

Thanks @Kristen Pol

here us the updated patch along with interdiff.

Kristen Pol’s picture

Issue tags: +Needs manual testing

The interdiff looks good, thanks. Haven't had a chance to manually test it yet.

Ruuds’s picture

The patch from #34 works great for me.

Kristen Pol’s picture

Manually tested with and without patch and it works as expected.

Without patch

With patch but without front page set to node/2

With patch but with front page set to node/2

Kristen Pol’s picture

I just read all the comments above and it wasn't clear to me that anyone actually reviewed the code. Seems like people were just testing that it worked. I only did a superficial review before so I'll see if someone on the bugsmash team can do a better code review.

maacl’s picture

Status: Needs review » Reviewed & tested by the community

Changes and Test look good to me. Patch works as intended.

This is something SEO tools give a warning about, so it would be nice to get this in.

catch’s picture

Status: Reviewed & tested by the community » Needs work

the patch looks good but there are a couple of issues:


FILE: ...upal/core/modules/content_translation/content_translation.module
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 707 | ERROR | [x] Object operator not indented correctly; expected
     |       |     12 spaces but found 14
 709 | ERROR | [x] Object operator not indented correctly; expected
     |       |     14 spaces but found 12
---------------------------------------------

This needs to be added to the cspell dictionary:

ontent_translation/tests/src/Functional/ContentTranslationLinkTagTest.php:130:14 - Unknown word (hreflangs)
sarvjeetsingh’s picture

Assigned: Unassigned » sarvjeetsingh
sarvjeetsingh’s picture

Assigned: sarvjeetsingh » Unassigned
Status: Needs work » Needs review
FileSize
3.49 KB
843 bytes

I have made the changes as suggested above and updated the patch.
please review, thanks!

abhisekmazumdar’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
167.85 KB
215.32 KB

Hi thanks @sarvjeetsingh for patch.

I applied the patch on 9.1.x.
Before patch:

After applying the patch:

The points said by @catch are covered on the latest patch.

  • catch committed 11118a3 on 9.1.x
    Issue #2796399 by Krzysztof Domański, mayurjadhav, pritish.kumar, heikki...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 11118a3 and pushed to 9.1.x. Thanks!

criz’s picture

Here is a reroll of the patch for 8.9.x, so that it applies for 8.9.6.

Piotr Pakulski’s picture

#46 reroll works fine for me for 8.9.6

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.