Using git revision as cache key

Hi there, I’m considering migrating https://chrisdown.name 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)
      site.data['gitrev'] = %x(git rev-parse --short HEAD).strip
    end
  end
end

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?{{ site.data["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