Skip to content
New issue

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

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

Already on GitHub? # to your account

Add hugo.IsServer as alias of site.IsServer #11510

Closed
earthboundkid opened this issue Sep 28, 2023 · 4 comments · Fixed by #11529
Closed

Add hugo.IsServer as alias of site.IsServer #11510

earthboundkid opened this issue Sep 28, 2023 · 4 comments · Fixed by #11529
Assignees
Milestone

Comments

@earthboundkid
Copy link
Contributor

I was changing some code from hugo.IsProduction and I tried writing hugo.IsServer, which it turns out does not work. This is should be site.IsServer instead. But why? I think the answer is that site.IsServer predates the hugo action. Now that we have hugo, I think site.IsServer should be removed from the docs (although maybe not actually removed for a long time) and hugo.IsServer should be added.

@earthboundkid earthboundkid changed the title site.IsServer and hugo.IsProduction are inconsistent Add hugo.IsServer as alias of site.IsServer Sep 28, 2023
@jmooring
Copy link
Member

I agree that's a better place for it, but also want to clarify that hugo.IsProduction and site.IsServer are two very different things:

$ hugo server -e production

{{ site.IsServer }} --> true
{{ site.IsProduction }} --> true

And I think hugo.Environment is the most useful of the three.

@earthboundkid
Copy link
Contributor Author

Yeah, I was changing the code because it was testing for prod but it really needed to be testing for server vs compiled.

@bep bep added this to the v0.120.0 milestone Oct 5, 2023
@bep
Copy link
Member

bep commented Oct 5, 2023

Yes, we should do this. I have found that the most useful construct in this department is:

{{ if ne hugo.Environment "development"  }}
{{ end }}

The above works if you have additional "production like" environments (staging ...).

So, maybe we should add a hugo.IsDevelopment too.

@jmooring jmooring self-assigned this Oct 5, 2023
jmooring added a commit to jmooring/hugo that referenced this issue Oct 5, 2023
jmooring added a commit to jmooring/hugo that referenced this issue Oct 5, 2023
@bep bep closed this as completed in #11529 Oct 6, 2023
bep pushed a commit that referenced this issue Oct 6, 2023
@github-actions
Copy link

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 Oct 28, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants