nicfab
December 19, 2021, 12:12pm
1
I want to deploy files now but they have to be published at the date set in PublishDate
.
I use the PaperMod theme.
I set in the frontmatter of the post I want to publish publishDate: 2021-12-20T07:00:00:00+00:00
I set in the config.toml
the following lines:
nableRobotsTXT = true
buildDrafts = false
buildFuture = true
buildExpired = true
[frontmatter]
date = [ "date", ":filename", ":default"]
publishDate = [ "publishDate", "date"]
lastmod = [ "lastmod", ":fileModTime", "publishDate"]
expiryDate = [ "expiryDate"]
However, doing the deploy the file with the date in the future appears published now.
Where am I wrong?
If you don’t want future posts to be published now then set:
buildFuture = false
nicfab
December 19, 2021, 2:39pm
4
I did it, but the post is published anyway.
What is the exact command you’re using to build the project?
nicfab
December 19, 2021, 3:02pm
6
I tried locally with all of the following ones:
hugo server
hugo server -D
hugo server --buildFuture=false
The post is published anyway.
BtW, I changed some lines in the config.toml as it follows:
theme = "PaperMod"
enableRobotsTXT = true
buildDrafts = false
buildFuture = false
buildExpired = true
[frontmatter]
date = ['date', 'publishDate', 'lastmod']
expiryDate = ['expiryDate']
lastmod = [':git', 'lastmod', 'date', 'publishDate']
publishDate = ['publishDate', 'date']
You need to share a sample repo that reproduces the issue and also mention which content file is the one being published when it shouldn’t.
Also which Hugo version are you using?
nicfab
December 19, 2021, 3:06pm
8
I’ll work on it
The latest: hugo v0.91.0+extended darwin/arm64 BuildDate=unknown
nicfab
December 19, 2021, 3:18pm
9
In this post: myhugo/content/post/publishdate.md at main · nicfab/myhugo · GitHub
You have set the publishDate
for tomorrow yet you have also set a date
for today.
The post is published because the date
parameter takes precedence over publishDate
.
To set future posts either use publishDate
on its own or set date
sometime in the future.
nicfab
December 19, 2021, 4:53pm
11
I have some doubts.
In the post you mentioned, I:
deleted the row with PublishDate
;
modified date
, changing it with date: 2022-05-25T07:00+00:00
Unfortunately, locally the post is published anyway.
What do you mean by “future”?
To me, tomorrow is the future.
This isn’t a date:
2021-12-21T07:00+00:00
This is:
2021-12-21T07:00:00+00:00
https://toml.io/en/v1.0.0#offset-date-time
1 Like
nicfab
December 19, 2021, 5:03pm
13
Thank you!
Now it woks.
The latest question: "Should I run ./deploy
tomorrow again, or the post will be published automatically?
How would it happen automatically? Think about it.
nicfab
December 19, 2021, 5:07pm
15
I want to know whether, after having changed the date with date: 2021-12-21T07:00:00+00:00
, if I run now ./deploy
to send all the local content to the server, the post will be published online tomorrow automatically or tomorrow should I run ./deploy
again.
With a future publishDate, the HTML page will not be created in the public directory when you run hugo
.
Let’s say I create seven pages: one to be published on Monday, the next on Tuesday, the next on Wednesday, etc. I will need to run hugo
every day.
nicfab
December 19, 2021, 5:13pm
17
jmooring:
With a future publishDate, the HTML page will not be created in the public directory when you run hugo
.
Let’s say I create seven pages: one to be published on Monday, the next on Tuesday, the next on Wednesday, etc. I will need to run hugo
every day.
I deleted PublishDate:2021-12-21T07:00:00+00:00
and I left only date: 2021-12-21T07:00:00+00:00
.
I understand that I have to run hugo server
(locally) or ./deploy
(to send the contents to the server) every time I want to publish the post on that date I input.
Is it so?
Run hugo on or after that date.
nicfab
December 19, 2021, 5:16pm
19
Thank you.
Now it’s clear to me.
Wouldn’t it be better to develop a system to automate the publication of scheduled posts?
That’s on the hosting/server side: triggers, cron jobs, etc.
https://discourse.gohugo.io/search?q=publishDate
1 Like