Skip to content

Theme fails to detect production environment #153

@sarahec

Description

@sarahec

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions