Skip to content

Hash Filters

Hash filters generate cryptographic hash values from strings. These are useful for cache busting, generating unique identifiers, or integrating with services that require hashed values.

Generates an MD5 hash of the input string.

Syntax:

{{ string | md5 }}

Output: A 32-character hexadecimal string.

{{ "hello@example.com" | md5 }}
{{ "Hello World" | md5 }}

Gravatar images:

{% assign email_hash = user.email | downcase | md5 %}
<img
src="https://www.gravatar.com/avatar/{{ email_hash }}?s=200&d=mp"
alt="{{ user.name }}"
>

Cache busting:

{% assign cache_key = page.updatedAt | md5 %}
<link href="{{ 'css/main.css' | asset_url }}&h={{ cache_key }}" rel="stylesheet">

Generates a SHA-1 hash of the input string.

Syntax:

{{ string | sha1 }}

Output: A 40-character hexadecimal string.

{{ "hello@example.com" | sha1 }}
{{ "Hello World" | sha1 }}

Generating unique IDs:

{% assign unique_id = block.id | append: now | sha1 | slice: 0, 8 %}
<div id="section-{{ unique_id }}">
...
</div>