Yes, a template for the homepage is a good option. But in case you always want to use the same header for every template with all JS/CSS links, you have two options to load a JS file only on the homepage:
1. You can check the URL of the page:
<@ if @{url} = '/' @>
<script ... ></script>
<@ end @>
2. Alternatively you can test the template name:
<@ if @{:template} = ... @>
...
<@ end @>
Note that @{:current}
is a boolean variable. It is true
in case the current context equals the URL of the currently requested page. That is very useful if you want to highlight the current page while iterating a pagelist - like in a navigation or similar. To get the current context, you can use either @{url}
or @{:origUrl}
. The URL of the homepage is always '/'
.