This template uses the eleventy-plugin-svg-sprite package which compiles an SVG Sprite and installs a shortcode to display SVG in any file (Markdown, Nunjucks etc).

🔥 Massive Thank You to Ryan Scherler and his Eventy Starter where I first learned about the svg-sprite package. Thanks also to Patrick Chong for creating eleventy-plugin-svg-sprite.

SVG Sprites : Managing Display, Colors, & Links

NOTE: The post, Managing Social Share, Author, and Footer Icons goes into a bit of detail on how to manage those elements.

SVG Sprites live in the /src/assets/svg/ directory and are currently used in this system on:

Adding Your Own SVGs to the System

If you want to add your own SVGs for use with the SVG Sprite system and SVG Shortcode, you’ll have to first add them to the /src/assets/svg/ directory and make sure they are named using the same syntax as the SVGs already present.

You should also open those SVGs in your text/coding editor and see how they have been modified for accessibility and to return the best Lighthouse optimization scores.

Using SVG Sprites in .md Content

If you’re happily typing along on that next great blog post and you realize what it really needs is a SVG, you’re in luck!

github icon

Just use the SVG Shortcode installed by eleventy-plugin-svg-sprite to insert a SVG anywhere and control its size, color, padding, position, float, etc. For example, the following code returns the GitHub SVG floating to the left:

{% svg "github", "mt-1 mr-2 h-10 w-10 text-blue-500 float-left" %}