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?
_plugins
directory in the root of your Jekyll project.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With