I’ve seen some discussions about get the current vs future date, but i’ve not found anything useful in my case.
Context
Sometimes i create multiple articles, linked by an href link, think about a guide or a walkthtrough.
Usually i want the articles to be published gradually over some weeks (i have a scheduled cronjob to do automate that).
The following “episodes” have a future published date, therefore they are published only after that date.
The issue
I create the links using the << ref >> shortcut as a url, setting the link to the next markdown file. My problem is that while i’m trying to build the hugo blog, there is usually a breaking error (REF_NOT_FOUND) which happens because the future post is still not “existing”.
ERROR 2021/03/19 15:21:32 [en] REF_NOT_FOUND: Ref "/path/2021-03-18-article-000264.md" from page "path/2021-03-18-article-000259.md": page not found
Expected Behaviour
Let’s say that
Page1 is published today (19 march)
Page 2 is scheduled to appear after 7 days (26 march)
There is a link from Page 1 to Page 2.
When Hugo build the site today, the link does not “appear” (or it’s empty, or pointing to self, it doesn’t matter), because the Page 2 does not exists today.
After the 26 of march, Hugo rebuild the site, this time the link is correctly written, because both pages exist.
Question
Is it possible to automate the expected behaviour or the only possible solution is for me is an “editorial” action, where i should change the article link only after the article has been published ?
{{ with .Get 0 }}
{{ if (site.GetPage .).PublishDate }}
{{ ref $.Page . }}
{{ end }}
{{ else }}
{{ errorf "The %s shortcode requires a single positional parameter. See %s" .Name .Position }}
{{ end }}
I’m not quite sure about the difference between “date” and “publishDate”, so i’m wondering if the script works in the same way if check the “date” property. (to avoid duplicating the properties, which would have the same value).