How to check if the site is on localhost?

Thanks, that’s a good Hugo resource for Go programmers. Not for people new to Go and Hugo, I think.

For others, I got it working with this:

{{ if eq (printf "%v" $.Site.BaseURL) "http://localhost:1313/" }}
   <!-- code for localhost only -->
{{ end }}

Thanks Bep!

2 Likes