Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Setting base href with TYPO3 TypoScript using site.base (site configuration)

For some legacy reasons I still need to add a base href tag in the header of the HTML page:

Naively, I thought this TypoScript would work:

page.headTag.append = TEXT
page.headTag.append.data = site.base
page.headTag.append.wrap = <base href="|">

Loosely based on baseURL documentation for v12.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But, this creates the following (HTML source code):

<base href="">

Double-checking if the site.base will resolve:

page >
page = PAGE
page.10 = TEXT
page.10.data = site:base
page.10.wrap = This is your base URL: |

This works! The output is:

This is your base URL: https://mysite.example.org

(The code snippet was taken verbatim from https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/SiteHandling/UseSiteInTypoScript.html#gettext)

I did not use config.baseURL because this will be deprecated in v12. I am on TYPO3 v11.

See also documentation of config.baseURL:

>Solution :

Please make sure to use the correct data value. You are using a dot instead of a colon.

page.headTag.append = TEXT
page.headTag.append.data = site:base
page.headTag.append.wrap = <base href="|">

https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Functions/Data.html#data-gettext

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading