Skip navigation

TYPO3 custom meta tags

Increasingly I find myself having to add custom meta data in order to validate my ownership of a site.  Both Yahoo and Google offer webmaster tools with the option of either adding a static html page or including custom meta tags.
Although its easy enough to quickly upload an html file most of my sites would require explicit tweaks to the .htaccess file to allow the plain html to be served.  Without the exception being added the request is caught by the application and a 404 is thrown.

Adding a custom meta tag is therefore the path of least resistance and with a TYPO3 site running TemplaVoila you have two options:

  1. Edit the underlying TemplaVoila source file (aka File reference)
  2. Use the headerData object to add the tag using TypoScript

I’d previously gone down the forst route as I couldn’t identify the correct meta object in the TSref but this requires updating the mapping of each Template Object that uses the source file.  Now I’ve found the elusive page.headerData object it allows the second, more straightforward solution.
This is the snippet I added to the Setup of my site template to enable me to use Yahoo’s Site Explorer:

?View Code TYPOSCRIPT
page.headerData.666 = TEXT
page.headerData.666.insertData=1
page.headerData.666.wrap = <meta name="y_key" content="|" />
page.headerData.666.value = 94b2aefda6132bxx

Adding the google.com verification code would just as simple:

?View Code TYPOSCRIPT
page.headerData.668 = TEXT
page.headerData.668.insertData=1
page.headerData.668.wrap = <meta name="verify-v1" content="|" />
page.headerData.668.value = LNIXg/7hvAc6p3zjr+QmWy+U6q0MFGRaVvCXWn1F4xx=

Remember that this technique can be used to add any additional head content you desire.

4 responses so far ↓

  • 1 Sadler // Sep 4, 2008 at 11:12 am

    Cheers – just the snippet I needed.

  • 2 Steve // Feb 25, 2009 at 2:38 pm

    It added in the meta tag, but it was all in lowercase, so when google checks it, it says they don’t match! Is it anything to do with the .case property of headerData ?

  • 3 Matt Bracewell // Feb 26, 2009 at 11:59 pm

    @Steve
    Sound like it – is that something you’ve fiddled with? I don’t recall “doing” anything extra to make it work like this so I guess you’ve got a subtly different setup somewhere – ‘fraid I can’t think where offhand. Is all your head output in lower case? Is your code exactly the same as mine or have you had to make your own tweaks?
    @Sadler
    You’re welcome!

  • 4 Koen Van Nuffelen // Feb 5, 2010 at 2:36 pm

    Easier way:

    new google style:
    page.meta.google-site-verification = ptMElEjwFamFTxaaAAyR-3DVpDxPU2Lxj7QXAiAKhL3

    old google style:
    page.meta.verify-v1 = ptMElEjwFamFTxaaAAyR-3DVpDxPU2Lxj7QXAiAKhL3

Leave a Comment