Relative Publishing Times

I am trying to use Hugo to publish class content for online classes. The problem I am trying to solve is that I want content to become available on specific dates, for example I want each weeks material to get published Saturday at Midnight. That is easy enough with an automated build and publishDate in the frontmatter.

The problem is that the courses are offered once every quarter, so there are hundreds of pages and it ‘resets’ every quarter.

What I would like to do is to somehow set a start date for a course and then essentially have the publishDates be relative to that, like courseStartDate + 7days. This would allow me to set one master date each quarter rather than having to update each page individually. Is there a way to get this sort of functionality? I know it probably isn’t built in, but maybe it is a problem someone has solved.

I haven’t tested anything; this is just speculation. Since archetypes support template functions, maybe you could pass the course start date to a script, then have that script do a bunch of hugo new commands, which use an archetype that does some date math …

If I understand archetypes correctly, that would create a lot of empty .md files that had potentially correct publishDates. Is there a way to get the archetype to update an existing file or to pull in some actual content with it?

I do think that this would potentially work to make frontmatter with the right date, but I am not sure how I could get content in there.

Yes, you would get a blank whatever.md file with the basic frontmatter, unless your archetype file contained content.

So that does not quite solve the problem then. :frowning: It would be nice for the initial creation of the pages though. :+1:

But the issue that I am trying to solve is that I want to basically reuse all of the content from one quarter to the next.

So in the fall quarter, after one week release topics A and B, after two weeks release C and D.

Then in winter it needs to start all over again from scratch. After a week of the winter term, release A and B, after two weeks release C and D.

All of the content is the same, but the dates are all different. They are the same relative to the start of the term, but that’s it.

What I’d do if it were my challenge, would be to create all the files I need with the same date, then use sed to do a search-replace on date in the set of files. Then I’d rename the new set of files appropriately and put them in position to be used.

That will probably be the approach I end up taking. I was hoping there might be a way to use a function within the frontmatter somehow to do it, if not, I think you are right, an external script is going to be the way to go.