I haven’t tried , but you should be able to use
time function to convert that
sale_ends string to
time.Time format, and then
.Unix to convert that time and
now time to seconds, and then take a difference of those. You can know if the time is already past if the difference is negative/positive. Based on the difference amount, you can also tell if the
sale_ends day is the same as
now (which is actually the date the site was last published, not necessarily today).
Related example: https://gohugo.io/functions/unix/#example-time-passed-since-last-modification
Also, I am assuming that you already looked at setting
expirydate in the front-matter? If you want to just not publish a post beyond certain date, just use that variable in the front-matter so that you don’t need to do that date math.