October CMS resources and help articles

Simple and to the point. Optimized by the community.

Include SVGs inline in themes

3
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:
==
<?php
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" %}

Discussion

0 comments

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