October CMS resources and help articles

Simple and to the point. Optimized by the community.

Include SVGs inline in themes

by octobertricks@luketowers.ca, last modified on September 21st, 2020

If you would like to include inline SVGs in your theme templates then you can do the following:

  1. Create a partial called include-svg.htm and put the following code in it:
function onStart() {
    $this['svgContents'] = File::get(base_path($this->file));
{{ svgContents|raw }}
  1. Include your desired SVG like so:
{% partial "include-svg" file="themes/mytheme/assets/images/mysvg.svg" %}



We use cookies to measure the performance of this website. Do you want to accept these cookies?