Bug #91353
closedEpic #89797: HrefLang / Canonical issues
Deactivation of Hreflang Tags not possible anymore
100%
Description
It should be possible to deactivate the generation of the hreflang tags via ...
unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Frontend\Page\PageGenerator']['generateMetaTags']['hreflang']);
... as described in the manual , but it does not (10.4.1).
I have tried whether disabling the canonical via the similar …
unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Frontend\Page\PageGenerator']['generateMetaTags']['canonical']);
… still works: yes, it does.
It looks like ...
TYPO3_CONF_VARS > SC_OPTIONS > TYPO3\CMS\Frontend\Page\PageGenerator > generateMetaTags > hreflang
… it is out of date. I can't even find it in the configuration module.
Background of the problem:
I created a language in the sites module whose content is not yet finished. This language version should be accessible to some people involved and who know the link, but for now there should not be an <link rel="alternate" hreflang="lang_code" href="url_of_page"/> entry. If I deactivate "Visible in Frontend", it unfortunately cannot be accessed at all, not even via the view-module in the backend:
Page Not Found The page did not exist or was inaccessible. Reason: Page is not available in the requested language
Therefore I thought it would be the easiest workaround to deactivate the complete hreflang-tag generation.
Updated by Georg Ringer over 4 years ago
- Category changed from Site Handling, Site Sets & Routing to SEO
- Assignee set to Richard Haeser
Updated by Benjamin Robinson over 4 years ago
Addendum: my suggestion would be to set up a checkbox "exclude from hreflang" in the site management for the languages. That way you could control this specifically for individual languages and you don't have to deactivate a language completely if it is still under construction on the one hand, but on the other hand should be made available to decision makers without BE access. The global unset for hreflang would then also no longer be absolutely necessary.
What I also don't like about a complete deactivation of a language: if for each language a separate domain is used and a language is hidden for the time being, then you only have a preview if you are logged in at the same time under the same domain in the BE. If you call the domain by mistake without being logged into the BE, a 404 is created. If the error handling is set to "show content from page", then the 404 content is also not accessible and an error entry is created in the log.
Updated by Oliver Bartsch over 4 years ago
The Hook was replaced by an PSR-14 Event. See: #86614
So there is no possibility to generally unset the generation. What you could do now is register an own listener which is executed after and unset the HrefLang tags.
However the documentation should be updated for this case.
Updated by Benjamin Robinson about 4 years ago
I think that, apart from the above example, there may still be other cases where it is necessary to deactivate the hreflang. For example, if you have a news module with a page browser that goes over 10 pages in one language but only 5 in another. So far the hreflang of page 10 would lead to a non-existent page 10 of the other language. So it would be better to deactivate it and it would be nice if this could even be done via TypoScript:
[request.getQueryParams()['tx_news_pi1']['widget_0']['currentPage'] && request.getQueryParams()['tx_news_pi1']['widget_0']['currentPage'] > 0]
page.config.hreflang = 0
[global]
(page.config.hreflang = 0 was suggested by Christoph at https://forge.typo3.org/issues/88242#note-5 )
So even an integrator could deactivate it, because the hook is rather something for developers.
Updated by Georg Ringer about 4 years ago
- Related to Epic #89797: HrefLang / Canonical issues added
Updated by Gerrit Code Review almost 4 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67315
Updated by Richard Haeser almost 4 years ago
For now I updated the docs (see review), but I also created https://forge.typo3.org/issues/93188 to work on a more easy way to disable the rendering of those tags.
Updated by Gerrit Code Review almost 4 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67315
Updated by Gerrit Code Review almost 4 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67315
Updated by Gerrit Code Review almost 4 years ago
Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67294
Updated by Richard Haeser almost 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 111b47c9638cc5fd46e2f8321709b04e9f8ff1af.
Updated by Richard Haeser almost 4 years ago
- Status changed from Resolved to Closed
Updated by Georg Ringer almost 4 years ago
- Related to Feature #93188: Possibility to disable hreflang per page added