diff --git a/README.md b/README.md index 9c37c65..36ffebf 100644 --- a/README.md +++ b/README.md @@ -274,19 +274,26 @@ Now enter [`localhost:1313`](http://localhost:1313/) in the address bar of your ## Production -To run in production (e.g. to have Google Analytics show up), run `HUGO_ENV=production` before your build command. For example: +To run in production (e.g. to have Google Analytics show up), the built-in [Hugo variable: Environment (`.Hugo.Environment`)](https://gohugo.io/variables/hugo/) will default to `production` when running `hugo` to build the site (whereas `hugo server` defaults to `development`), or this can be configured explicitly via the CLI-tag via `hugo --environment 'production'`, or run `HUGO_ENV=production` before your build command. For example: ``` HUGO_ENV=production hugo ``` -Note: The above command will not work on Windows. If you are running a Windows OS, use the below command: +Note: The above command will not work on Windows. If you are running a Windows OS, use the below command if using the command shell: -``` +```bat set HUGO_ENV=production hugo ``` +...or the following if using PowerShell: + +```powershell +$env:HUGO_ENV='production' +hugo +``` + ## Contributing If you find a bug or have an idea for a feature, feel free to use the [issue tracker](https://github.com/theNewDynamic/gohugo-theme-ananke/issues) to let me know. diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 1b5d721..19ccdd9 100755 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ hugo.Generator }} {{/* NOTE: For Production make sure you add `HUGO_ENV="production"` before your build command */}} - {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} + {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") | or (eq .Hugo.Environment "production") }} {{ else }} @@ -33,7 +33,7 @@ {{- template "_internal/schema.html" . -}} {{- template "_internal/twitter_cards.html" . -}} - {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} + {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") | or (eq .Hugo.Environment "production") }} {{ template "_internal/google_analytics_async.html" . }} {{ end }} {{ block "head" . }}{{ partial "head-additions.html" . }}{{ end }} diff --git a/layouts/partials/func/style/GetMainCSS.html b/layouts/partials/func/style/GetMainCSS.html index 9e3c24d..e74fdd0 100644 --- a/layouts/partials/func/style/GetMainCSS.html +++ b/layouts/partials/func/style/GetMainCSS.html @@ -59,7 +59,7 @@ css asset directory we add to aforementioned slice */}} {{ $options := dict "enableSourceMap" true "precision" 6 }} {{ $style = $style | resources.ToCSS $options | minify }} {{/* We fingerprint in production for cache busting purposes */}} - {{ if eq (getenv "HUGO_ENV") "production" }} + {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") | or (eq .Hugo.Environment "production") }} {{ $style = $style | fingerprint }} {{ end }} {{/* We're ready to set returning variable with resulting resource */}} diff --git a/layouts/robots.txt b/layouts/robots.txt index 7a24e82..287563c 100644 --- a/layouts/robots.txt +++ b/layouts/robots.txt @@ -1,6 +1,6 @@ User-agent: * # robotstxt.org - if ENV production variable is false robots will be disallowed. -{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} +{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") | or (eq .Hugo.Environment "production") }} Allow: / Sitemap: {{.Site.BaseURL}}/sitemap.xml {{ else }}