This plugin adds replaces the src for images with a CDN url when the original URL is relative.
- Add the gem to your
Gemfile:gem 'jekyll-images-cdn', github: 'fastruby/jekyll-images-cdn'
- Run
bundle installto install the gem - Add the following to your
_config.yml:plugins: - jekyll-images-cdn
The plugin automatically edits all image and picture elements with relative paths for the src attribute prepending the defined CDN base url.
You can configure the plugin in the _config.yml file:
images_cdn:
base_cdn_url: https:my_cdn.comOr you can use the ASSET_HOST environment variable:
ASSET_HOST=https:my_cdn.com bundle exec jekyll build -d ../public/blog
Note that, if both are defined,
ASSET_HOSThas priority