Hugo Logo

I don’t recommend using this - as it prevents you from testing this functionality locally – but if you wanted a script to only load on ‘production’ this is a quick hack.

1
2
3
4
5
{{ if in (.Site.BaseURL | string) "www.example.com" }}
<script>
    // ... script / code goes here 
</script>
{{ end }}
Tags: Scripts, Production, Development

Read more from my blog for an introduction and quick tips on developing in Hugo or UCTD.

Meet the author

Photo for Damien Saunders
Damien Saunders
An experienced management consultant and business leader interested in digital transformation, product centred design and scaled agile. If I'm not writing about living with UCTD (an autoimmune disease), I'm probably listening to music, reading a book or learning more about wine.
Find our more about me.