Skip to content

Check hugo.Environment == “production” rather than HUGO_ENV=production environment variable #611

@mhansen

Description

@mhansen

Hi, this is forked off from #217 to track a systemic fix for how Docsy by-default sets all your pages to noindex. I think this is a fairly high-severity issue: sites migrating to Docsy might find themselves delisted from Google until Google reindexes.

https://discourse.gohugo.io/t/checking-env-variable-prevents-site-from-being-indexed-by-google-on-aws/23707
suggests that instead of

{{ if eq (getenv “HUGO_ENV”) “production” }} 

we should use

{{ if eq hugo.Environment “production” }}

Then running with

hugo will build for production config.

hugo.Environment is defined at https://gohugo.io/variables/hugo/

I wonder how much backwards-compatibility concerns there are here for people updating though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions