New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .Site.IsServer to determine if the site was built in server mode #4478

Closed
mydoghasworms opened this Issue Mar 7, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@mydoghasworms
Copy link

mydoghasworms commented Mar 7, 2018

As per the following Discourse discussion:

https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860

It would be helpful to put a condition into a template that can determine whether the page is being built/server by hugo server (and not necessarily with the -D flag, for which there is already a variable).

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.

@bep bep added this to the v0.38 milestone Mar 7, 2018

@bep bep assigned bep and unassigned bep Mar 7, 2018

@bep bep added the Enhancement label Mar 7, 2018

@bep bep changed the title Please add feature to distinguish, in a template, when Hugo server is running Add .Site.IsServer to determine if the site was built in server mode Mar 7, 2018

@bep bep modified the milestones: v0.38, v0.39 Mar 20, 2018

@kaushalmodi

This comment has been minimized.

Copy link
Member

kaushalmodi commented Mar 27, 2018

But isn't this already possible by simply checking if .Site.BaseURL is "localhost"? I do that all the time.

@bep

This comment has been minimized.

Copy link
Member

bep commented Mar 27, 2018

But isn't this already possible by simply checking if .Site.BaseURL is "localhost"? I do that all the time.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment