How do I configure Jekyll to serve SVG?
jekyll, svg
Solution
- Create a `_plugins` directory in the root of your Jekyll project.
- Create a file called `svg_mime_type.rb` in `_plugins`
Add this to `svg_mime_type.rb`:
require 'webrick'
include WEBrick
WEBrick::HTTPUtils::DefaultMimeTypes.store 'svg', 'image/svg+xml'
That's it! Next time you start Jekyll, it will use the proper MIME type for SVG.
Problem
I use Jekyll for building my web site, and I want to start serving SVG. Browsers won't recognize SVG as an image unless it is sent with the proper MIME type. Unfortunately, Jekyll does not set the MIME type by default. (To be fair, Jekyll uses Webrick for the HTTP server) How do I tell Jekyll to use the `image/svg+xml` mime type for SVG?