Closed instruccionesaldorso closed 2 years ago
Hi @instruccionesaldorso,
thank you for your input. Your right, with an active EXT:seo the hreflang tags are duplicated.
I don't want to change the behavior of a whole TYPO3 installation with a minor version update. So I added a hint in the documentation about this configuration option in commit 713a5f0. In TYPO3 10.4 and 11.5 this hook isn't used anymore. Instead the EXT:seo uses an EventListener. I haven't found a good way to disable this EventListener. But you can always write a custom EventListener in your own theme/sitepackage extension which resets the hreflang tags from EXT:seo.
In the long run the EXT:bgm_hreflang would need a whole refactoring with more breaking changes. Then I want to use this core API directly. But this will take some time :-)
Greetings, Marco
P.S. This is not yet released, I'm waiting for some tests on other issues...
Thanks for your wonderful input. If you could give us a hint how to write this custom EventListener, that would be really helpful. We're in the middle of a v10 upgrade. I'll ask the TYPO3 community as well.
Hi, writing an EventListener is documented here: https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/Events/EventDispatcher/Index.html#implementing-an-event-listener-in-your-extension.
You have to register your class in your theme extension (MyVendor/MyExtension) in Configuration/Services.yaml
services:
MyVendor\MyExtension\EventListener\ResetCoreHrefLangTags:
tags:
- name: event.listener
identifier: 'myvendor/resetCoreHrefLangTags'
after: 'typo3-seo/hreflangGenerator'
event: TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent
And then implement a class MyVendor\MyExtension\EventListener\ResetCoreHrefLangTags where you overwrite the core's hreflang array with an empty array:
<?php
namespace MyVendor\MyExtension\EventListener;
use TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent;
class ResetCoreHrefLangTags
{
public function __invoke(ModifyHrefLangTagsEvent $event): void
{
$event->setHrefLangs([]);
}
}
It should work like this, but I couldn't test the code right now. Most parts are just copied from the documentation and EXT:seo :-)
I could finally solved this issue today: here it is explained how to disable the auto-generation in v10: https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/Events/Events/Frontend/ModifyHrefLangTagsEvent.html And there is even a better setting over v11: https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Setup/Config/Index.html#disablehreflang
I close this issue. Thanks for your support!
Whenever EXT:seo is installed and a pagetree contains several languages, functionality to generate hreflang tabs is doubled. Could these lines be included over ext_localconf.php for this extension? I think this fix proposal was proposed in the past in a separate issue.
+if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('seo')) {