Skip to content

astrob0t/jekyll-git-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Download the jekyll-git-data.rb file to your Jekyll _plugins directory.

The following variables can be used inside your liquid template.

  • {{ site.data['shorthash'] }} -- git shortened hash
  • {{ site.data['longhash'] }} -- git hash
  • {{ site.data['currentbranch'] }} -- the current active branch

Use

When the site is being generated by Jekyll, the plugin retrieves the Git data of the website source code and exposes it as a value in site.data.

Git build badges

This feature is helpful when you want to show your current commit build data as a badge on your website. This makes use of the Github Badges.

For example, in your footer.html:

<a href="//github.com/<user>/<repo>/commit/{{ site.data['longhash'] }}" rel="nofollow">
   <img src="https://img.shields.io/badge/build-{{ site.data['shorthash'] }}-blue.svg?logo=github" alt="GitHub Commit">
</a>

Cache Busting

This can also be used for cache busting. Appending your static resources (CSS, JS, etc.) by the git hash will force the browsers to reload the assets every time you deploy a new version of the site. Instead of generating a random number, you can use the git commit hash instead.

For example, in your default.html:

<link rel="stylesheet" href="/css/main.css?{{ site.data['shorthash'] }}"/>

About

Jekyll plugin for generating current build's Git metadata

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages