ExtraStatic: powerful and easy publishing

Skip to content

Fix image processing for RSS

Chris Dawson requested to merge fix_images_processing_for_rss into main

Image links inside RSS were broken, so this fixes that.

And, this MR will also serve as documentation for the images support in Svekyll.

You can put images directly into your markdown like: <img src="image.png"/>.

However, you might want to specify the images inside the YAML front matter (YFM).

title: My blog

Then, inside your markdown you can use this:

---
title: My blog post
attachments:
  firstfile: firstfile.png
  secondfile: secondfile.png
---

Hello, this is a post with images.

<img src={attachments.firstfile}/>

Another image is here:

<img src={attachments.secondfile}/>

When this is rendered, the resulting HTML will look like this (partially reduced to remove body and html tags...):

...
<p>Hello, this is a post with images.</p>

<img src="firstfile.png"/>

<p>Another image is here:</p>

<p><img src="firstfile.png"/></p>
...

If you want to host the images outside the repository, on a separate image hosting site, you can do this using the attachments section of the _config.yml . If you need to specify the hosting service, you can do that using the root element. This is useful if you are using a service like ExtraStatic which allows you to send emails to create blog posts. ExtraStatic will automatically push your image to the files.extrastatic.dev hosting service, and create a markdown file with the images referenced inside the YFM for you as well as the <img> tags. But, if you are not using ExtraStatic, you probably want to use your own hosting service. You can do that by adding root to your attachments hash.

title: My blog
attachments:
  root: https://mycustomimageservice.com/images

Then, you will see image like this:

...
<p>Hello, this is a post with images.</p>

<img src="https://mycustomimageservice.com/images/firstfile.png"/>

<p>Another image is here:</p>

<p><img src="https://mycustomimageservice.com/images/firstfile.png"/></p>
...

This structure gives you flexibility if you want to change the hosting service. You can change just the _config.yml and all links will be regenerated with the new root.

Edited by Chris Dawson

Merge request reports