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

Support for .Hugo.Environment variable #453

Closed
tlindsay42 opened this issue Dec 12, 2021 · 1 comment
Closed

Support for .Hugo.Environment variable #453

tlindsay42 opened this issue Dec 12, 2021 · 1 comment

Comments

@tlindsay42
Copy link
Contributor

Just discovered that the .Hugo.Environment variable is not evaluated as an alternative to HUGO_ENV environment variable and .Site.Params.env theme parameter. Testing for this condition would be an improvement.

Example

https://github.com/theNewDynamic/gohugo-theme-ananke/blob/v2.8.0/layouts/_default/baseof.html#L12

    {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production")  }}
      <META NAME="ROBOTS" CONTENT="INDEX, FOLLOW">
    {{ else }}
      <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
    {{ end }}
@tlindsay42
Copy link
Contributor Author

I've thought about creating an IsProduction returning partial that would preserve the former behaviour while introducing hugo.Environment but cannot think of one. Can you?

Had an idea for how to approach this. Sending a new PR.

tlindsay42 added a commit to tlindsay42/gohugo-theme-ananke that referenced this issue Jan 3, 2022
* Adds GetEnvironmentName and IsProduction partial functions, which
  improve DRY
* Add prioritization for determining environment name, which favors the
  existing methods: the `HUGO_ENV` environment variable and site config
  `env` theme parameter
* Adds `useHugoEnv` theme parameter to use the value of
  `.Hugo.Environment` for the build environment name
tlindsay42 added a commit to tlindsay42/gohugo-theme-ananke that referenced this issue Jan 3, 2022
tlindsay42 added a commit to tlindsay42/gohugo-theme-ananke that referenced this issue Jan 9, 2022
@davidsneighbour davidsneighbour added this to the unplanned milestone Sep 19, 2024
@davidsneighbour davidsneighbour removed this from the unplanned milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants