After a certain time period, I’d like these posts to “expire” so that they do not appear in the list page, but the single post still needs to exist. The functionality I’m looking for is similar to sites like eBay, where an expired auction does not appear in the main results, but the actual listing still exists.
I’ve been achieving this by trying two different things:
{{range .Pages}}
{{if not .Params.expire}}
...
{{end}}
{{end}}
.Params.expire is set to true for posts that have expired.
The other method I’ve tried is
{{range .Pages}}
{{if lt now .Params.valid_through}}
...
{{end}}
{{end}}
.Params.valid_through is a date set in front matter.
This logic is adding quite a bit to build time. I have about 2000 posts with half being expired. Is there a more efficient way of doing this?
Not sure if I can make your construct work as there is not a predefined date that my posts will expire. So might expire in 7 days, others in 14 days etc. That’s why I created a custom variable in front matter.