If the site's front page is set to a node, the node's metatags overwrite those set for the Front Page in the Metatag configuration. This is different than how this module behaved in Drupal 7, so I'm not sure if it's by design or not. If it is by design we should probably add some documentation to prevent confusion.

If you have the front page of the site set to something that's not an entity (so, the default /node view path for example) the Front Page metatags will take effect if they're set. If however you create a node, then set the system's font page to the path of that node, the Front Page tags are overwritten by those of the node.

If you follow through the code in metatag.module can can see the Front Page tags set in line 238, then they're overwritten in the array_merge at 256 because metatag_get_route_entity returns the entity you're using as the front page.

As a workaround you can of course add the Metatag field to the content type you're using as a front page, then set the tags on the individual node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adamwhite created an issue. See original summary.

adamwhite’s picture

Issue summary: View changes
DamienMcKenna’s picture

The reverse was a problem on D7 ;-)

Need to think on this.

ericshell’s picture

I can confirm that I am also experiencing this issue.

I may use your workaround @adamwhite for the time being unless I can find another solution.

Raphael Apard’s picture

metatag_get_default_tags() function get front tags and then overrides them with getting metatag from route entity.
If frontpage is a node, we need to make metatag not getting content tags for this node right ?

Same think if 403 or 404 page is a node. Here a patch that reverse overrides, but maybe we will have a reversed problem.

DamienMcKenna’s picture

Status: Active » Needs review

Cool, a patch! Thanks Raphael!

PS when you upload a patch please set the issue status to "needs review", that'll kick off the testbots to make sure there are no regressions.

Status: Needs review » Needs work

kyberman’s picture

Thank you for #5 patch! I tested that and it works as expected. I hope it will be committed soon.

Raphael Apard’s picture

No way to get tests results ?

DamienMcKenna’s picture

I think a slightly different approach should be taken.

Need to add some tests for this.

DamienMcKenna’s picture

In order to commit this we need some tests to confirm the functionality works as intended.

Raphael Apard’s picture

Thanks. Works for me. Somebody esle confirm that this patch is working and set this issue to reviewed ?

DamienMcKenna’s picture

@Raphael Apard: Just to be clear, the module needs code tests, not just people manually checking it.

I think there should be a src/Tests/MetatagFrontpageTest.php that checks the different scenarios for how the front page can work:

  • The front page config is enabled, its meta tags should be used.
  • The front page config is disabled and the front page is set to a node, the node's meta tags should be used.
  • The front page config is disabled and the front page is a custom route, the default global config should be used.

We need tests for at least the first two of those before I'd be willing to commit it.

DamienMcKenna’s picture

Status: Needs review » Needs work
gaurav.goyal’s picture

Assigned: Unassigned » gaurav.goyal
Status: Needs work » Needs review
FileSize
8.33 KB
5.76 KB

Here goes the first patch which includes tests.

Below are the details for test cases:

1. When front page config is enabled - All front page cases (node, custom route) should show metatags configured for the front page.
2. When front page config is disabled - If a node is front page show node metatags, and if custom route then show global metatags.

dpacassi’s picture

I've tested the patch mentioned in #16 on a multilingual site with D8 RC1 and it works great, thanks!

  • DamienMcKenna committed 2aead96 on 8.x-1.x
    Issue #2650408 by Raphael Apard, DamienMcKenna, gaurav.goyal, dpacassi,...
DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2699381: Plan for Metatag 8.x-1.0-beta8 release

Committed. Thanks!

Status: Fixed » Closed (fixed)

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

DamienMcKenna’s picture

Assigned: gaurav.goyal » Unassigned