HUGO

Does hitting “publishDate” trigger a new build?

Or does is the unpublished data (data where “publishDate” > actual date and time) already in the build, and it just gets rendered at “publishDate.”

Please don’t ask questions solely in the title. It’s difficult to select.

Does hitting “publishDate” trigger a new build?

What does “hitting” entail? Are you referring to the live development server in Hugo?

Sorry about using the title to ask the question, and thanks for asking for clarification.

By “hitting,” I mean when the actual date and time equal “publishDate.”

Sorry, I can’t figure out what you mean.

Hugo does not run as a service; it does not monitor content after you build your site. New builds can be “triggered” manually, via cron jobs, CI actions, etc.

If you plan to take advantage of the publishDate, and author content (with draft = false) in advance of the date you wish it to be publicly visible, you will need to run hugo again on or after the publishDate.

From the command line type hugo list future to see a list of content with future publish dates:

content/foo,2020-09-12T07:43:11-04:00
content/bar,2020-08-07T14:12:16-04:00

You could “blindly” run hugo and deploy every hour or day via a cron job, but I would do it selectively by hashing the output of hugo list future, and compare that to the hash generated during the last run (requires storing the hash value in a permanent file). If the hash value has changed, build and deploy, otherwise skip. Yes, this will trigger an unecessary build when new future content is added, but it’s better than building blindly.

A more complex mechanism could store the output of the hugo list future command, then use diff to look at changes; deletions would trigger a build, additions would be ignored.

1 Like

Thank you, jmooring. I believe I’m starting to understand the relationship between publishDate and a necessary build.

All my data will be in the file Day 1, and each content item will have its publishDate. Does having that information, which I see I should have provided when asking my question (sorry about not having done that), change things? Since there will be no additions or deletions to the file, but all pre-existing content items will “drip out“ to the user as per their publishDate, there would be a nul result from a diff between lists, and no build would be required when current datetime = publishDate. I’m I correct about that?

Do I understand correctly?

No.

No. No build would be required when current datetime < publishDate.

Why don’t you try it and then come back to the forum if you have further questions.

Mmmmm … To say may be more simply how Hugo works :

  • Everything is computed and generated according to the conditions when you build the site.
  • If condition change (ex date of the day) nothing happens by itself on hugo ==> you need to build again the site to take in account the new conditions and generate new pages/informations.
2 Likes

Thank you divinerites. This answers my question directly even as — or maybe because— you reversed its form. :upside_down_face: