# Theme/site version (hash)

**URL:** <https://zola.discourse.group/t/theme-site-version-hash/2104>\
**Category:** Feature requests\
**Created:** [April 7, 2024, 7:04pm UTC](https://zola.discourse.group/t/theme-site-version-hash/2104 "2024-04-07T19:04:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie137](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/charlie137/32/1140_2.png) [@charlie137](https://zola.discourse.group/u/charlie137)\
**Post date:** [April 7, 2024, 7:04pm UTC](https://zola.discourse.group/t/theme-site-version-hash/2104/1 "2024-04-07T19:04:10Z")

</div>

Could we add versioning/themes’ or sites’ hashes for cases where `git` is used? It could be just variables that are detected automatically prior to the rendering, or a function returning the current (commit) hash for the site/theme. The default call would return the current hash for the project, and `theme` would do the same for the theme.

To avoid bulky `git2-rs` and its dependencies, we could just check `HEAD`/`refs/$BRANCH` files in `.git/` manually. Hardcoded common branch names sound like the trickiest part (if we forget about `dirty` states).

Maybe later we could get fancy and also check tags, but I’m not sure how many keep tagging their themes if no package infra is involved (and that’s the case for PWAs, mostly).

---

<div class="post-metadata">

**Author:** ![charlie137](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/charlie137/32/1140_2.png) [@charlie137](https://zola.discourse.group/u/charlie137)\
**Post date:** [June 16, 2024, 2:34pm UTC](https://zola.discourse.group/t/theme-site-version-hash/2104/2 "2024-06-16T14:34:28Z")

</div>

Implemented head hash but `load_data()` does not work with variables:

```auto
{%- if config.extra.footer.hash == true %}
  {%- set head_branch = load_data(path=".git/HEAD") | replace(from="ref: ", to="") %}
  {#- load_data(path=head_branch_path)v is not working #}
  {%- if head_branch is containing("refs/heads/trunk") %}
    {%- set_global hash = load_data(path=".git/refs/heads/trunk") %}
  {%- elif head_branch is containing("refs/heads/main") %}
    {%- set_global hash = load_data(path=".git/refs/heads/main") %}
  {%- elif head_branch is containing("refs/heads/master") %}
    {%- set_global hash = load_data(path=".git/refs/heads/master") %}
  {% else %}
    {% if get_env(name="GITHUB_SHA", default="NONE") != "NONE" %}
      {%- set_global hash = get_env(name="GITHUB_SHA") %}
    {% elif get_env(name="COMMIT_REF", default="NONE") != "NONE" %}
      {%- set_global hash = get_env(name="COMMIT_REF") %}
    {% elif get_env(name="CI_COMMIT_SHA", default="NONE") != "NONE" %}
      {%- set_global hash = get_env(name="CI_COMMIT_SHA") %}
    {% endif %}
  {%- endif %}
{%- endif %}

```

@keats is this a bug?
