Installation:
composer.json under "require":
"mi3ll/jekyll-site-helpers": "dev-master"
_plugins directory:
"extra": {
"installer-paths": [
"./src/_plugins/{$name}": ["mi3ll/jekyll-site-helpers"]
]
}
composer update to install.Verify Setup:
src/_plugins/jekyll-site-helpers/.bundle exec jekyll serve).First Use Case:
relativity filter to make a path relative to the current page:
{{ '/assets/image.png' | relativity }}
cachebuster filter to append a timestamp for cache busting:
{{ '/assets/image.png' | cachebuster | relativity }}
Asset Path Handling:
relativity to dynamically generate relative paths for assets (e.g., images, CSS, JS) based on the current page location.<img src="{{ '/images/logo.png' | relativity }}" alt="Logo">
Cache Busting:
cachebuster and relativity to ensure users always fetch the latest version of assets.<link rel="stylesheet" href="{{ '/css/styles.css' | cachebuster | relativity }}">
Configurable Cache Busting:
filebuster with a custom variable in _config.yml (e.g., cache_version) to avoid hardcoding timestamps or requiring file existence._config.yml:
cache_version: v2
<script src="{{ '/js/app.js' | filebuster }}"></script>
Base Path for Links:
{{ base }} tag to dynamically generate the root path of the site (useful for multi-level directories or subdirectories).<a href="{{ base }}/about">About</a>
Liquid Templates:
index.html, _layouts/default.html).jekyll serve --watch to preview changes.Build Automation:
Custom Variables:
_config.yml to define reusable variables for filebuster (e.g., js_version, css_version).Filter Order Matters:
cachebuster before relativity to avoid incorrect path concatenation.{{ '/assets/image.png' | relativity | cachebuster }} <!-- May break paths -->
File Existence for cachebuster:
cachebuster requires the file to exist to read its modification time. Use filebuster if files don’t exist yet or for non-file-based versions.Jekyll Plugin Directory:
_plugins is in the root of your Jekyll site (not src/_plugins unless configured). Adjust the Composer installer-paths if needed.Ruby Dependencies:
gem install jekyll).Check Plugin Loading:
jekyll build --trace to verify the plugin is loaded. Errors here indicate path or dependency issues.Test Filters Isolated:
test-filters.html) to validate filters individually:
{% assign test_path = '/test/path' %}
Relative: {{ test_path | relativity }}
Cachebusted: {{ test_path | cachebuster }}
Filebusted: {{ test_path | filebuster }}
Log Filter Output:
debug tag to inspect filter results:
{{ '/test' | relativity | debug }}
Custom Filters:
jekyll-site-helpers/lib/jekyll-site-helpers.rb) to add new filters or modify existing ones.minify filter to compress asset paths.Configuration Overrides:
jekyll-site-helpers.Variable Scope:
filebuster with global _config.yml variables for team-wide consistency:
cache:
js: v1.2
css: v3.0
{{ '/js/app.js' | filebuster: site.cache.js }}
filebuster for static versions (e.g., v1, v2) over timestamps to reduce rebuild overhead.relativity results in a variable if used repeatedly:
{% assign relative_path = '/assets/img' | relativity %}
<img src="{{ relative_path }}/logo.png">
How can I help you explore Laravel packages today?