Using git revision as cache key

Hi there, I’m considering migrating from Jekyll to Zola, since it’s the last thing I really use in Ruby. Most plugins are easily able to be rewritten as shortcodes. One I am not sure about the best way to go about is this one:

module GitRevPlugin
  class GitRev < Jekyll::Generator
    safe true
    def generate(site)['gitrev'] = %x(git rev-parse --short HEAD).strip

I then use this as a cache key later to make sure the version of the CSS is the same as the page being displayed:

<link rel="stylesheet" href="/css/style.css?{{["gitrev"] }}">

I see a couple of ways I could do this in Zola, but both seem less than ideal since they both rely on an external build script:

  1. Dynamically generate a shortcode with a build script before running Zola, embedding the current git revision.
  2. Put the current git revision in an environment variable using a build script, and then query that from a shortcode.

Is there some way to avoid having to create an external build script for this? Thanks!

It’s not available right now. It could be added but it’s something we would want to add automatically on every page render I think, rather than on a function call? See Feature request: build datetime · Issue #2375 · getzola/zola · GitHub for something related