mirror of
https://github.com/theNewDynamic/gohugo-theme-ananke.git
synced 2025-06-08 17:22:46 +00:00
Add support for .Hugo.Environment variable (#453)
This commit is contained in:
parent
c7b9901e01
commit
eb2ef5dc31
13
README.md
13
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.
|
||||
|
@ -9,7 +9,7 @@
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
{{ 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") }}
|
||||
<META NAME="ROBOTS" CONTENT="INDEX, FOLLOW">
|
||||
{{ else }}
|
||||
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
|
||||
@ -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 }}
|
||||
|
@ -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 */}}
|
||||
|
@ -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 }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user