javascripthtmlexpressionengine

Adding Javascript file into Expression Engine


For the life of me I cannot get a javascript file to load / be added correctly to an expression Template file (Ie.: _footer)

I've tried all these and nothing.

<script src="{base_url}/scripts/main"></script>

<script src="{base_url}/scripts/main.js"></script>

<script src="{base_path}/scripts/main.js"></script>

Thank you for any input


Solution

  • I recommend you check out this article which goes about explaining how to set up templates, including partials, layout etc. It says it all far better than I could.

    Templating Intro (ExpressionEngine University)

    To answer your question though, you want to use the site_url variable.

    <script src="{site_url}/scripts/main.js"></script>