jekyll-svg-viewer brings the BT SVG Viewer frontend to static Jekyll sites. It ships a Liquid tag for rendering interactive SVG diagrams, automatically injects the required JavaScript/CSS, mirrors the shortcode options from the WordPress plugin, and includes a standalone preset builder page for crafting configurations. Source code lives at github.com/ttscoff/jekyll-svg-viewer.
Installation
Add the published gem to your Jekyll site:
# Gemfilegem"jekyll-svg-viewer"
Need the latest unreleased changes? Point Bundler at GitHub instead:
Run bundle install, then build or serve your site as usual (bundle exec jekyll build / bundle exec jekyll serve). The viewer assets are copied into _site/assets/svg-viewer/ as part of the build.
Liquid Tag Usage
Place the svg_viewer tag anywhere Liquid tags are supported:
Only fields you override are required. src, center_x, and center_y remain per-tag settings.
Screenshots
Preset EditorSVG Viewer Front End
Localized Assets & Automatic Injection
The gem copies the viewer script, stylesheet, and localization JSON into _site/assets/svg-viewer/. Whenever a page renders {% svg_viewer %}, the plugin:
Marks the document so the CSS/JS tags are injected into <head> once during post_render.
Ensures the asset files exist by the post_write phase.
You don’t need to manually edit layouts or partials—the assets appear only on pages that use the tag.
Preset Builder Page
The plugin also generates a preset editor at /svg-viewer/preset-builder/. It mirrors the WordPress admin experience:
Enter an SVG path, tweak zoom/controls/colors, and load a live preview.
Capture the current viewport to populate center_x / center_y.
Copy a ready-to-use Liquid tag.
Generate a _config.yml snippet (excluding src and the captured center) inside a modal dialog.
This is the quickest way to dial in viewer options without memorizing every attribute.
Development Notes
The gemspec bundles the compiled frontend assets. If you update wp-svg-viewer/js/svg-viewer.js or related CSS, re-copy them into jekyll-svg-viewer/assets/svg-viewer/.
The preset builder JavaScript (assets/svg-viewer/preview/preset-builder.js) is framework-free and mirrors the PHP logic used by the WordPress plugin.
A minimal smoke-test site is available in example_site/. Run scripts/build-example.sh to install dependencies and build it locally.