Can't evaluate field Hugo in *hugolib.PageState

Hello, and thank you for making this beautiful piece of software.

I have run out of options trying to figure out this problem. I have searched the forums for similar old posts but none of the solutions seem to work for me, or i am missing something, and searching the quoted error strings i am getting on google fetches me only one single result which is from a failed build log on netlify - not mine or related to my project at all.

So… here I am seeking your help.

The error I get (in short)

can't evaluate field Hugo in *hugolib.PageState

The longer error log:

Summary
> hugo
Start building sites …
hugo v0.95.0-9F2E76AF+extended windows/amd64 BuildDate=2022-03-16T14:20:19Z VendorInfo=gohugoio
ERROR 2022/03/26 14:11:04 render of "taxonomy" failed: execute of template failed: template: _default/terms.html:3:9: executing "_default/terms.html" at <partial "header.html" .>: error calling partial: "C:\Users\kamal\system-notes\quick-tips\themes\er\layouts\partials\header.html:5:8": execute of template failed: template: partials/header.html:5:8: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/03/26 14:11:04 render of "section" failed: execute of template failed: template: _default/list.html:3:9: executing "_default/list.html" at <partial "header.html" .>: error calling partial: "C:\Users\kamal\system-notes\quick-tips\themes\er\layouts\partials\header.html:5:8": execute of template failed: template: partials/header.html:5:8: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/03/26 14:11:04 render of "taxonomy" failed: execute of template failed: template: _default/terms.html:3:9: executing "_default/terms.html" at <partial "header.html" .>: error calling partial: "C:\Users\kamal\system-notes\quick-tips\themes\er\layouts\partials\header.html:5:8": execute of template failed: template: partials/header.html:5:8: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/03/26 14:11:04 render of "taxonomy" failed: execute of template failed: template: _default/terms.html:3:9: executing "_default/terms.html" at <partial "header.html" .>: error calling partial: "C:\Users\kamal\system-notes\quick-tips\themes\er\layouts\partials\header.html:5:8": execute of template failed: template: partials/header.html:5:8: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:3:9: executing "index.html" at <partial "header.html" .>: error calling partial: "C:\Users\kamal\system-notes\quick-tips\themes\er\layouts\partials\header.html:5:8": execute of template failed: template: partials/header.html:5:8: executing "partials/header.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
Total in 31 ms

The template partial snippet that seems relevant to this is below:

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta content='text/html; charset=utf-8' http-equiv='content-type' />
{{ partial "open_graph.html" . }}
{{ .Hugo.Generator }} <!-- this line seems to be the one, that's all i can tell from the error message -->

My hugo env below:

> hugo env
hugo v0.95.0-9F2E76AF+extended windows/amd64 BuildDate=2022-03-16T14:20:19Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.18"

I have tried to build the exact same code on a linux machine as well and get the exact same error messages (only different file paths).

Hugo env for the linux machine:

Summary
hugo v0.95.0-9F2E76AF+extended linux/amd64 BuildDate=2022-03-16T14:20:19Z VendorInfo=gohugoio
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.18"

If this doesn’t seem like something obviously missing or wrong in configuration (since this same template is known to work for someone else, with the difference mainly being in config that I setup separately without knowing much of what i am doing but following the reference from here… and another source mentioned in the config file below).

Below is the full copy of my config (i was getting the same error before adding all of the content after the theme in this config as well.):

Summary
baseURL = 'http://quick-tips.morjal.com/'
languageCode = 'en'
title = 'Quick Tips'

# got most of the below stuff from 
# https://github.com/tbrown122387/my_academic_site_v2/blob/master/config/_default/config.toml
# ---

# ---
# Theme
# ---

theme = "er"

# Enable users to switch between day and night mode?
day_night = true

# Choose a font size.
# Sizes: XS (extra small), S (small), M (medium), L (large - DEFAULT), XL (extra large)
# font_size = "L"

# -----------------------------------------------------------------------------------

# Website type
#   Improve how search engines understand your site.
#   For personal sites, choose "Person".
#   For organizations and projects, choose from https://schema.org/Organization#subtypes
#   E.g. Person, Organization, LocalBusiness, Project, EducationalOrganization
site_type = "LocalBusiness"

# Local business type (optional)
# If you entered "LocalBusiness" above, choose the type of business from https://schema.org/LocalBusiness#subtypes
local_business_type = "Quick Tips Vendor"

# Organization name (optional)
# Enter an organization or project name. Defaults to the site title from `config.toml`.
org_name = "hmmm"

# Description for social sharing and search engines. If undefined, superuser role is used in place.
description = "Quick tips from my everyday computer use that i discovered and found useful for everyone. I tend to forget these as soon as i am done with them, and that's not a very good thing."

# -----------------------------------------------------------------------------------

# personal details
# ---
# Enter contact details (optional). To hide a field, clear it to "".
email = "****"

# ------------------------
#  Advanced options below 
# ------------------------

# Get last modified date for content from Git?
# enableGitInfo = true

# Default language to use (if you setup multilingual support)
defaultContentLanguage = "en"
hasCJKLanguage = false  # Set `true` for Chinese/Japanese/Korean languages.
defaultContentLanguageInSubdir = false
removePathAccents = true  # Workaround for https://github.com/gohugoio/hugo/issues/5687

summaryLength = 30  # Listing summary length in words. Also, see `abstract_length` in `params.toml`.
paginate = 10  # Number of items per page in paginated lists.
enableEmoji = true
enableRobotsTXT = true
footnotereturnlinkcontents = "<sup>&uparr;</sup>"
ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"]

# Workaround Hugo publishing taxonomy URLs as plurals - consistently use singular across Academic.
[permalinks]
  authors = "/author/:slug/"
  tags = "/tag/:slug/"
  categories = "/category/:slug/"
  publication_types = "/publication-type/:slug/"

[build]
  publish="public"
  command="hugo"

[outputs]
  home = [ "HTML", "RSS", "JSON", "WebAppManifest" ]
  section = [ "HTML", "RSS" ]

[mediaTypes."application/manifest+json"]
  suffixes = ["webmanifest"]

[outputFormats.WebAppManifest]
  mediaType = "application/manifest+json"
  rel = "manifest"

# Taxonomies.
[taxonomies]
  tag = "tags"
  category = "categories"
  publication_type = "publication_types"
  author = "authors"

# Related content.
[related]
  threshold = 80.0
  includeNewer = true
  toLower = true

  [[related.indices]]
    name = "title"
    weight = 60.0

  [[related.indices]]
    name = "summary"
    weight = 50.0

  [[related.indices]]
    name = "tags"
    weight = 80.0

  [[related.indices]]
    name = "categories"
    weight = 70.0

  [[related.indices]]
    name = "authors"
    weight = 20.0

There are many similar posts in the forum with similar topic “Can’t evaluate field x… in type *hugolib.pageState” but trying solutions posted there did not resolve my problem.

Thanks for your time and help. :pray:

PS: here’s something purely for the amusement quotient:

Summary

It’s been a while I saw this: only 1 unique result for a query on google.

quick update:

I downloaded a theme named paper and updated only this line:

theme = "paper"

in the config.toml and everything works with a few warnings.

Maybe I was working with a slightly broken or old theme.

If you’re still interested to help resolve the error with the previous theme, please respond, otherwise I’ll close this thread in a few days. Thanks!

Replace the above with {{ hugo.Generator }} instead.

4 Likes

Thank you! This got rid of all the errors.

Btw, was this because something changed in recent hugo releases?
(Also, I am Go-illiterate, so perhaps something going on there?)

I think so. I am also new to Hugo. But Hugo keeps changing rapidly and some themes don’t keep up. I opted out from using a theme and made my own design due to this.

2 Likes

The hugo global variable was introduced in Hugo v0.53.0 (more than 3 years back!). You probably happened to use a theme that didn’t get updated.

3 Likes

Yes, but we had a deprecation warning about it for a very long time.

4 Likes

I am sure there was. Also, the Hugo experience remains just as smooth as it was when I first tried it a few years ago when I tried it with one of the stock themes listed in the themes directory now.

This was just a odd outlier case, I guess, where I was too drained to figure things out while trying to tweak a legacy project.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.