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.
Comment | File | Size | Author |
---|---|---|---|
#16 | interdiff.txt | 5.76 KB | gaurav.goyal |
#16 | if_the_site_s_front-2650408-16.patch | 8.33 KB | gaurav.goyal |
#11 | metatag-n2650408-11.patch | 2.57 KB | DamienMcKenna |
Comments
Comment #2
adamwhite CreditAttribution: adamwhite at JMR Logics commentedComment #3
DamienMcKennaThe reverse was a problem on D7 ;-)
Need to think on this.
Comment #4
ericshell CreditAttribution: ericshell as a volunteer commentedI 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.
Comment #5
Raphael Apard CreditAttribution: Raphael Apard commentedmetatag_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.
Comment #6
DamienMcKennaCool, 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.
Comment #9
kybermanThank you for #5 patch! I tested that and it works as expected. I hope it will be committed soon.
Comment #10
Raphael Apard CreditAttribution: Raphael Apard commentedNo way to get tests results ?
Comment #11
DamienMcKennaI think a slightly different approach should be taken.
Need to add some tests for this.
Comment #12
DamienMcKennaIn order to commit this we need some tests to confirm the functionality works as intended.
Comment #13
Raphael Apard CreditAttribution: Raphael Apard commentedThanks. Works for me. Somebody esle confirm that this patch is working and set this issue to reviewed ?
Comment #14
DamienMcKenna@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:
We need tests for at least the first two of those before I'd be willing to commit it.
Comment #15
DamienMcKennaComment #16
gaurav.goyal CreditAttribution: gaurav.goyal at Innoraft commentedHere 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.
Comment #17
dpacassiI've tested the patch mentioned in #16 on a multilingual site with D8 RC1 and it works great, thanks!
Comment #19
DamienMcKennaCommitted. Thanks!
Comment #21
DamienMcKenna