`ref`working in `hugo serve` but not on a static build

This seems buggy, but I’m just learning how hugo fits together and I might well have got something upside down, or left out a part somewhere.

I’ve got this inside a file content/posts/nbd/towards-a-better-nbd.md:

window.location = "{{< ref "/pages/thanks-for-signing-up.md" >}}";

This file renders fine under hugo serve, and the generated link works. I have a file content/pages/thanks-for-signing-up.md present, and it renders when I visit http://localhost:1313/pages/thanks-for-signing-up/.

However, when I run hugo --destination=../public, it fails with this error:

Building sites … ERROR 2018/05/05 12:07:08 error processing shortcode "_internal/shortcodes/ref.html" for page "posts/nbd/towards-a-better-nbd.md": template: _internal/shortcodes/ref.html:1:73: executing "_internal/shortcodes/ref.html" at <ref .Page (.Get 0)>: error calling ref: No page found with path or logical name "pages/thanks-for-signing-up.md".

There doesn’t seem to be any combination of pathname parts I can pass to ref to get it to see the file when I do a static build, despite it working fine under hugo serve.

I’m using the Kiss template, and hugo version says this:

 $ hugo version
Hugo Static Site Generator v0.41-DEV-8B03C51 linux/amd64 BuildDate: 2018-04-30T21:16:27+0100

Have I done something wrong, or is this a bug?

Alright, I ran the command hugo -d=../public and I received the following error message:

Building sites … ERROR 2018/05/07 04:05:11 error processing shortcode "_internal/shortcodes/ref.html" for page "DirA/DirAA/thething.md": template: _internal/shortcodes/ref.html:1:73: executing "_internal/shortcodes/ref.html" at <ref .Page (.Get 0)>: error calling ref: No page found with path or logical name "hereis.md".
ERROR 2018/05/07 04:05:11 error processing shortcode "_internal/shortcodes/relref.html" for page "DirA/DirAA/thething.md": template: _internal/shortcodes/relref.html:1:76: executing "_internal/shortcodes/relref.html" at <relref .Page (.Get 0...>: error calling relref: No page found with path or logical name "hereis.md".

Set the front matter variable draft in hereis.md to false and the site decided to build.

Bingo. Looks like it treats pages with draft: true as not existing, from ref's point of view. I wonder if there’s a way to have a more descriptive error message to remind you when you’ve forgotten to publish something…

Thanks!