Skip to content
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 · 3 comments · Fixed by #4541
Closed

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

mydoghasworms opened this issue Mar 7, 2018 · 3 comments · Fixed by #4541

Comments

@mydoghasworms
Copy link

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
Copy link
Contributor

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

@bep
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.

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants