Skip to content

Commit

Permalink
theme(fix): use internal methods to evaluate environment
Browse files Browse the repository at this point in the history
closes #625
closes #733
closes #453
closes #574

Signed-off-by: Patrick Kollitsch <[email protected]>
  • Loading branch information
davidsneighbour committed Oct 21, 2024
1 parent 9332bad commit cc6da23
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 */}}
{{ $production := eq (getenv "HUGO_ENV") "production" | or (eq site.Params.env "production") }}
{{ $production := hugo.IsProduction }}
{{ $public := not .Params.private }}
{{ if and $production $public }}
<meta name="robots" content="index, follow">
Expand Down Expand Up @@ -51,13 +51,14 @@
{{- template "_internal/schema.html" . -}}
{{- template "_internal/twitter_cards.html" . -}}

{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }}
{{ if hugo.IsProduction }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ block "head" . }}{{ partial "head-additions.html" . }}{{ end }}
</head>

<body class="ma0 {{ $.Param "body_classes" | default "avenir bg-near-white"}}{{ with getenv "HUGO_ENV" }} {{ . }}{{ end }}">
{{- $environment := hugo.Environment | default "production" -}}
<body class="ma0 {{ $.Param "body_classes" | default "avenir bg-near-white"}} {{ $environment }}">

{{ block "header" . }}{{ partial "site-header.html" .}}{{ end }}
<main class="pb7" role="main">
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/func/style/GetMainCSS.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
{{ $options := dict "enableSourceMap" true "precision" 6 }}
{{ $style = $style | css.Sass $options | minify }}
{{/* We fingerprint in production for cache busting purposes */}}
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ if hugo.IsProduction }}
{{ $style = $style | fingerprint }}
{{ end }}
{{/* We're ready to set returning variable with resulting resource */}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/robots.txt
Original file line number Diff line number Diff line change
@@ -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") -}}
{{/* robotstxt.org - if we are in production, allow access, else deny */ -}}
{{ if hugo.IsProduction -}}
Allow: /
Sitemap: {{ "/sitemap.xml" | absURL }}
{{ else -}}
Expand Down

0 comments on commit cc6da23

Please sign in to comment.