hugo-theme-mini icon indicating copy to clipboard operation
hugo-theme-mini copied to clipboard

Theme fails to detect production environment

Open sarahec opened this issue 1 year ago • 0 comments

Google reports the site isn't being indexed. Hugo is being run in production mode.

Each generated page contains

<meta name="generator" content="Hugo 0.121.1">
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">

but shouldn't in a production build.

Investigation

Looking at layouts/partials/head.html @ lines 6-11:

{{/* 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")  }}
  <META NAME="ROBOTS" CONTENT="INDEX, FOLLOW">
{{ else }}
  <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
{{ end }}

Per https://gohugo.io/functions/hugo/environment/ the hugo command builds with a production environment, but the theme isn't detecting this.

Solution

Use Hugo.IsProduction in the environment check instead.

sarahec avatar Jan 12 '24 17:01 sarahec