From f8026666f3cb7867ba67bc12800eb501b2589753 Mon Sep 17 00:00:00 2001 From: Brooke <12855764+goingforbrooke@users.noreply.github.com> Date: Wed, 10 May 2023 21:21:49 -0700 Subject: [PATCH] Fix: shortcode images don't load after build This fixes an issue where images added with the [`image` shortcode](https://github.com/pawroman/zola-theme-terminimal#image) are visible via `zola serve` but not `zola build`. It works by [prepending](https://tera.netlify.app/docs#concatenation) the site's base URL to external image URLs so `https://www.awesomesite.com/flower.png` is just as valid as `http://127.0.0.1:1111/flower.png`. External images are differentiated from internal images by the presence of `http` at the beginning of their URL. Fixes issue #36. --- templates/shortcodes/image.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html index 410be76..091eeb8 100644 --- a/templates/shortcodes/image.html +++ b/templates/shortcodes/image.html @@ -1,3 +1,8 @@ {% if src %} + {# If the image's URL is internal to the site... #} + {% if src is not starting_with("http") %} + {# ... then prepend the site's base URL to the image's URL. #} + {% set src = config.base_url ~ src %} + {% endif %} {% endif %}