`hugo server` and future articles

I see there’s a buildFuture config option. I’m using hugo server running in a Docker container hosted on my Rancher infrastructure. If I were to publish an article intended to go public Monday today, with Monday’s date, would hugo server respect the buildFuture option and not show it until Monday?

If not, are there any other ways to get this behavior? Maybe my template could exclude content with dates set in the future somehow?

You will have to trigger a rebuild on Monday somehow …

… you can run in server watch mode and touch that content file … but I would:

Dump hugo server (it is meant for development) and do a regular Hugo build to a static file server every n hours (or minutes or whatever). Cron is good for this.

Got it. Cron and static files are a useful solution when you’ve got everything on a single server or at least know where your code will run. In the case of Docker/Rancher, my site’s server could end up on any number of container hosts, and I don’t think there’s a cron equivalent. I thought about running the Hugo build process and dumping the files out to an Nginx server or something, but I have to run some sort of server either way so it might as well be Hugo.

I can just push my repo on Monday and trigger a restart then, but what about having the server rebuild the site on receiving a signal? Then I could run docker kill -s ... on the container at some point on Monday and trigger a rebuild? I suppose that isn’t too different than just restarting, but maybe it could keep existing connections open and just pause transmission, stop accepting new requests and wait until others are satisfied, etc.

Well, I presented the obvious and simplest solution. If Docker makes simple hard you should try anyway.

I would think that if you’re able to run hugo server in a Docker container, something ala while true do hugo sleep 100 fi should also be a walk in the park …

If not, the Docker guys should look hard into the mirror and shout loud.

If you’re using Docker what you probably want to do is have a Docker container based on nginx, https://hub.docker.com/_/nginx/. Assuming no additional configuration on the nginx side then you would have something like this.

FROM nginx
COPY public /usr/share/nginx/html

You would then have a cron job that runs hugo and then builds and pushes the Dockerfile.

If you have a revision control system I would recommend using the open source version of Drone, http://readme.drone.io/, which runs builds in Docker containers and allows you to publish Docker containers. You can then just trigger Drone. There’s also a Rancher plugin which can then update your service when a new build occurs.