How to Unpublish Event After Certain Date


#1

Greetings, Jekyll forum! I just redesigned my company’s new website and built everything with Jekyll. I absolutely love it!

Anyway, we are an event-driven organization, so we have event and class pages that must be taken down after the dates have passed. So far we have unpublished pages manually, but because we have so many events (especially during summer) the other employees that edit our website have requested a way to make these events come down automatically.

I haven’t been able to find any simple methods to accomplish this, and it doesn’t look like this can be done without a plugin of some sort.

One (or both) of the following would accomplish the aforementioned task:

  • Have published: true in the YAML header change to published: false on a specified, future date
  • Have all categories in the YAML header disappear on a specified, future date (this way the pages can be viewed, but will not appear in pages that pull and display specific categories)

Does anyone know of a solution, or should I consider writing a plugin for this? Thanks for all of your help! :slight_smile:


#2

This is a very interesting Jekyll use case I must say… May I ask you where do you keep the source code of your company’s website?

AFAIK, Jekyll site has the following lifecycle: [PROCESS FILES] -> [SERVE OUTPUT].

And what you are looking for is: [PROCESS FILES] -> [SERVE OUTPUT] -> [REPEAT ON DATE X].

Depending on how you handle your source code and where you host your output, you would be able to exploit some other techniques that are outside of Jekyll scope but give you the desired result.

For instance, a scheduled job on your server (if that’s the case) to restart the process, therefore when Jekyll generates pages for newly published events it also takes down expired ones.

So, knowing more about the technical side of your project would help to suggest a technique that fits your business case and environment constraints.


#3

Hey there! Sorry for the late reply, we have been swamped recently.

We host our website source code here.

If there isn’t already a plugin like this, then I think one would have to be created. For example, having a YAML header value like “unpublish-on: 08-27-2017 00:00:00” or “publish-until: 08-27-2017 00:00:00”, or something similar that would unpublish an event on a certain date would help tremendously. Perhaps I will look into writing a Jekyll plugin when I get some spare time.


#4

Lot’s of ways to skin that cat. Off the top, the easiest thing I could think of would be to include an “unpublish-on” variable in the event’s front matter as you suggest—then, when you are outputting events on the site, do a check against {{ site.time }} and only output those items that are greater than.

And, obviously, you’d have to also automate a build/deploy process every day—at midnight I guess? Lot’s of ways to do that, look at Netlify, or Deploybot, Travis-CI, etc.