Expose the git commit id in website

Is it possible to expose/append a full git commit ID in a Jekyll website on GitHub Pages? Similar to the sbt-buildinfo plugin for Scala-powered websites.

It should look like this at the end of the website source code (e.g. membership.theguardian.com):

<!-- build-commit-id: 370fa99f0cf1a2acc8b273a37d359e3a43b084e1 -->

I found this old plugin on GitHub for self-hosted usage but this doesn’t work for GitHub Pages and it uses short git commit IDs.


PS: I want to implement this in my Jekyll website:

have you seen
https://help.github.com/articles/repository-metadata-on-github-pages/

maybe build version?

Thanks but it doesn’t display the git commit rev id in the website source code (https://github.com/suriyaakudo/cdn.suriyaa.tk/blob/gh-pages/_layouts/default.html#L14) at https://cdn.suriyaa.tk/.

You have to configure the target repo in _config.yml :

repository: suriyaakudo/cdn.suriyaa.tk 

See jekyll-github-metadata documentation

1 Like

This sounds interesting, may I know the use-case, where do you want it to use?

I think you want site.github.build_revision

You’re using the site.git. namespace which could be the problem.

1 Like

I see. This was the issue:

This works:

Thank you. :blush: