Hugo build vs Hugo server inconsistent HELP!

I’m trying to build a shortcode to list a summary of pages from a specific section of the site on any page. I’ve run into an inconsistency between “hugo server” and just “hugo”. Here is an example:

In my shortcode .html file:

{{ with .Site.GetPage "section" "work" }}
{{ .Pages }}
{{ end }}

When using “hugo server --watch” the {{ .Pages }} call prints

Pages(15)

When using “hugo” to build for production {{ .Pages }} prints

Pages(0)

It seems that the section subpages are not being populated properly with the normal hugo build command. I’ve looked at all the cli flags and can’t seem to find anything that would account for it working fine in server mode and not in build mode.

Is this a bug or am I missing something?

[EDIT]

I just tried hugo -w. The first time it builds, I get

Pages(0)

but if I save the shortcode template file (which triggers a filesystem change and thus a rebuild) it outputs

Pages(15)

like it’s supposed to.

This definitely seems like a bug.

I cannot reproduce this bug. Can you tell me a bit more? For example:

  1. Your operating system
  2. Your version of Hugo (hugo version)
  3. What are you trying to by calling .Pages without anything else? Are you trying to range through those pages? Are you trying to get the content for that index page?
  4. Are you running hugo’s server or hugo’s build with any flags (e.g. --buildDrafts or --publishFuture)?

Hopefully I can help.

Sure.

  1. OS X 10.12.4
  2. Hugo v.19 (I also tried the Dev branch from homebrew (v.20), The problem was still there.
  3. Yes. I’m trying to range over a subset (first 3 in this instance) of those pages and render some of their metadata.
  4. I’ve tried some of the flags but it hasn’t seemed to make a difference. For me to be able to reproduce calling just “hugo” and “hugo server -w” seems to show the problem on my machine.

Let me know if you need anything else.

Thanks.

Please register an issue at

And I cannot reproduce it either, so it would be good if you could link to a project that shows this behaviour.