Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add .Site.IsServer to determine if the site was built in server mode #4478
As per the following Discourse discussion:
It would be helpful to put a condition into a template that can determine whether the page is being built/server by
This would be helpful for the case where you want to test the site in its final form (no drafts) but want to switch off, e.g. analytics or ads.
changed the title
Please add feature to distinguish, in a template, when Hugo server is running
Mar 7, 2018
Not if you run your server with something other than "localhost". I do that all the time. You could, of course, adjust that logic to also check for that hostname, but that would hardly be very portable.