#101: Simplifying environment detection

This commit is contained in:
Maksim Iakunin 2021-10-05 16:18:47 +03:00
parent f996392dda
commit 4d405ead5d
No known key found for this signature in database
GPG Key ID: 629DE6EA48DAF1F4
4 changed files with 7 additions and 9 deletions

View File

@ -167,9 +167,7 @@ Icon should be "static/fa-icons/google.svg"
If you want font awesome icons, download "Font Awesome For Desktop" and open svg directory. If you want font awesome icons, download "Font Awesome For Desktop" and open svg directory.
### Google Analytics ### Google Analytics
Only works for production environment. You either build your site with variable like Only works for production environment.
`HUGO_ENV=production hugo --minify`
or just put `env: production` to `params` section of config.
### Multilingual mode ### Multilingual mode
Check config/example usage in [exampleSiteMultilingual](https://github.com/Mitrichius/hugo-theme-anubis/tree/master/exampleSiteMultilingual) directory and documentation on [Hugo site](https://gohugo.io/content-management/multilingual/). Check config/example usage in [exampleSiteMultilingual](https://github.com/Mitrichius/hugo-theme-anubis/tree/master/exampleSiteMultilingual) directory and documentation on [Hugo site](https://gohugo.io/content-management/multilingual/).

View File

@ -41,7 +41,7 @@
<meta property="article:tag" content=""> <meta property="article:tag" content="">
<meta property="article:publisher" content="https://www.facebook.com/XXX"> --> <meta property="article:publisher" content="https://www.facebook.com/XXX"> -->
{{ if and (.Site.GoogleAnalytics) (or (eq (getenv "HUGO_ENV") "production") (eq .Site.Params.env "production")) }} {{ if and (.Site.GoogleAnalytics) (hugo.IsProduction) }}
{{ template "_internal/google_analytics.html" . }} {{ template "_internal/google_analytics.html" . }}
{{ end }} {{ end }}

View File

@ -9,7 +9,7 @@
{{ if $resource }} {{ if $resource }}
{{ $resource := $resource | resources.ExecuteAsTemplate $targetFilename . }} {{ $resource := $resource | resources.ExecuteAsTemplate $targetFilename . }}
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} {{ if hugo.IsProduction }}
{{ $resource = $resource | resources.Minify }} {{ $resource = $resource | resources.Minify }}
{{ end }} {{ end }}
{{ $resource = $resource | resources.Fingerprint "sha256" }} {{ $resource = $resource | resources.Fingerprint "sha256" }}

View File

@ -1,6 +1,6 @@
User-agent: * User-agent: *
# robotstxt.org - if ENV production variable is false robots will be disallowed. # robotstxt.org - if environment is not `production` then robots will be disallowed.
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} {{ if hugo.IsProduction }}
Disallow: Disallow:
{{ else }} {{ else }}
Disallow: / Disallow: /