# \[SOLVED\] Inject an SVG file into my HTML

**URL:** <https://discourse.gohugo.io/t/solved-inject-an-svg-file-into-my-html/7446>\
**Category:** support\
**Created:** [July 15, 2017, 3:47am UTC](https://discourse.gohugo.io/t/solved-inject-an-svg-file-into-my-html/7446 "2017-07-15T03:47:47Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [August 5, 2017, 10:41pm UTC](https://discourse.gohugo.io/t/solved-inject-an-svg-file-into-my-html/7446/10 "2017-08-05T22:41:41Z")

</div>

Just for the hell of it, @keauval, at the content level, you could do this as a shortcode:

```auto
<!--layouts/shortcodes/svg.html-->
{{$svg := .Get 0}}
{{ $svg | readFile | safeHTML }}

```

Then within the body copy/content of `*.md`:

```auto
{{< svg "static/svgs/your-svg.svg" >}}

```

This assumes, obviously, that you’re keeping your svgs as static assets a la images.

As a matter of fact, you could do something similar if you were trying to create a sort of content “snippet” that you want to add in content (i.e., `*.md`) files using `.GetPage`. The following assumes you have a `content/snippets` folder.

> **Note:** I’m doing this off the cuff and haven’t tested this like the above svg example:

```auto
<!--layouts/shortcodes/snippet.html-->
{{$snippet := .Get 0}}
{{ with .GetPage "page" "snippets" $snippet }}{{.Content}}{{end}} 

```

Then in your content file, you could call it like:

```auto
{{< snippet "my-snippet.md" >}}

```

You’d have to disable the `snippets` section, however, if you don’t want files in the `snippets` folder to render full-blown html files. (Again, not tested…but if anyone tries it, let me know.)

---

_[View the full topic](https://discourse.gohugo.io/t/solved-inject-an-svg-file-into-my-html/7446)._
