Search code examples
typo3typoscripttypo3-6.2.x

How to get the baseURL in a Typo3 template


I defined with typoscript the baseURL with the following code:

page.config.baseURL = http://www.website.nl/

Now I want to use the baseURL in the html template for a reference to a image. How can I add this url to the template? Tried the following but is not working.

<img src="{baseURL}images/sicma.png" width="70" height="28" alt="sicma">

Solution

  • Put it into a constant first:

    baseURL = http://www.website.nl/
    

    then use it in setup

    page.config.baseURL = {$baseURL}
    
    temp.logo = TEXT
    temp.logo.value = <img src="{$baseURL}images/sicma.png" width="70" height="28" alt="sicma">
    

    Of course, you have to assign temp.logo to the template.

    But isn't baseURL precisely there so you don't have to write absolute paths?