We created a home page at /node/123 and set this as the "Default front page" in "Basic site settings". This brings the user to the correct page when "/" is entered in a browser. This also creates:
<link rel="canonical" href="/node/123" />
which is not correct -- it should be href="/".
This behavior has a very negative side-effect, the page is listed by Google with a URL of https://dom.ain/node/123.
Comments
Comment #2
timmillwoodI don't believe this is a node specific issue.
Comment #3
joshi.rohit100I think its related to the node as this is rendered by NodeViewController but not sure if its an issue or not as same could be handled by some page_attachment_alter or node_view_alter().
Comment #4
raphaeltbm commentedWell, that seems to be an issue from the SEO point of view.
Is it Node or more globally Entity related, i'm not sure, but it's definitely managed by
NodeVieControllerwhich loop on$node->uriRelationships()to add#attachedthings.Don't really know if it should be fixed globally in the core. Don't know too, if it has to be fixed in the core, should it be handled in
NodeViewController->view()or inEntity->toUrl()to cover every cases of entity which could be setted as a frontpage, to manage the canonical url of this specific entity correctly everywhere?If the controller is updated, there is maybe a risk of side-effect because
html_head_linkis a special case which add data forhtml_headand forhttp_headerattachments inHtmlResponseAttachmentsProcessor. Should be careful about theshortlinkcase managed inview()too.If the entity class is updated, there is a high risk of side-effects and breakings, because lot of code/modules made tests and assumptions about the returned value of this function for an entity in a "canonical" rel context (search for
toUrl('canonical'). The 'canonical' term / usage is not really the same there.Maybe, to not break things, a mix of both, create a kind of extra
frontpage_awareparameter managed intoUrland use that inNodeViewControllerand all other contexts which needs the user/seo friendly URL?I would add something like that in
NodeViewControlleras a quickfix for the moment:edit: if not managed somewhere in the core, as said, this situation can be handled via an
hook_page_attachments_alter()or installing the Metatag module which allow you to have more granular control, case per case.Comment #5
raphaeltbm commentedI close this issue and will move my last comment in #1255092: url() should return / when asked for the URL of the frontpage.
It seems to be a bigger problem and i'm not really sure at what level it should be done to fix it globally and not have to manage the frontpage url case everywhere, everytime. It's a often forgotten case.
Comment #6
mdixoncm commentedJust stumbled over this issue - obviously there is a conversation around a proper fix - but for a quick fix, the metatag module has functionality to set a specific canonical and shortlink (and anything else) on the front page ...