Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme fails to detect production environment #153

Open
sarahec opened this issue Jan 12, 2024 · 0 comments · May be fixed by #154
Open

Theme fails to detect production environment #153

sarahec opened this issue Jan 12, 2024 · 0 comments · May be fixed by #154

Comments

@sarahec
Copy link

sarahec commented Jan 12, 2024

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 sarahec linked a pull request Jan 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant