theNewDynamic / gohugo-theme-ananke

Ananke: A theme for Hugo Sites
https://ananke-theme.netlify.app
MIT License
1.16k stars 1.16k forks source link

Support for .Hugo.Environment variable #453

Closed tlindsay42 closed 1 week ago

tlindsay42 commented 2 years ago

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 commented 2 years ago

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.