Search code examples
typo3hreflang

Maintain hreflang external pages in typo3


I would like to maintain the hreflang for pages in Typo3 7.6.19. This is not possible automatically, because the pages are external and different.

With Yoast-SEO this possibility (at least in my version) does not come along. It is an old Typo3 version, so I cannot use the extension bgm_hreflang from the TER.

Anyone an idea?

The structure of the hreflang meta is known. https://developers.google.com/search/docs/advanced/crawling/localized-versions


Solution

  • I think I found out. I checked at which position the hreflang was generated:

    headerData {
    
        10 = HMENU
        10 {
            special = language
            special.value = 0,1
            special.normalWhenNoLanguage = 0
            1 = TMENU
            1 {
                NO = 1
                NO {
                    stdWrap.cObject = TEXT
                    stdWrap.cObject {
                        value = de || en
                    }
                    linkWrap = <link rel="alternate" hreflang="|
                    doNotLinkIt = 1
                    after.cObject = TEXT
                    after.cObject {
                        stdWrap {
                            wrap = " href="|" />
                            typolink {
                                parameter.data = TSFE:id
                                #page:uid
                                additionalParams = &L=0 || &L=1
                                returnLast = url
                                forceAbsoluteUrl = 1
                                addQueryString = 1
                                addQueryString.method = GET
                                addQueryString.exclude = gclid,L,id,cHash,no_cache,backPid
                            }
                        }
                    }
                }
    
                CUR = 1
                CUR.doNotShowLink = 1
    
                # No Translation
                USERDEF1 = 1
                USERDEF1.doNotShowLink = 1
    
                USERDEF2 < .CUR
            }
        }
     }
    

    And then overwritten by the template extension per page:

    page.headerData.10 >
    page.headerData.10 = TEXT
    page.headerData.10.value (
    (...)
    <link rel="alternate" href="https://example.com/" hreflang="x-default" />
    )
    

    Of course, it would be nicer if the editor would only have to enter urls as HTML code, but for the moment it fits.