Reputation: 459
I'm unable to get Hugo to load inline javascript when embedded within posts. The javascript I'm attempting to import is an email sign up form. From other examples, the syntax seems correct. Are there any settings within the site or theme that would prevent javascript from loading?
Hugo version: v0.74.1 Theme: hello-friend-ng
Post and front matter
---
author:
name: "author"
date: 2020-04-03
linktitle: Inline javascript
type:
- post
- posts
title: Inline javascript
tags: ["debug"]
---
_Should show a email sign up form_
<script async data-uid="481686e31f" src="https://unique-writer-1890.ck.page/481686e31f/index.js"></script>
Thanks!
Upvotes: 1
Views: 1140
Reputation: 1791
I think this is one of the most frequently asked questions in the Hugo world.¹ Starting with Hugo v0.60.0, the default Markdown renderer is Goldmark and Goldmark defaults to ignoring raw HTML, such as <script ...
. To use raw HTML, you need to specify something like this in your config.toml:
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
I wrote about this in fragments 14 and 15 in my Hugo Tips and Fragments.
Sidenote: Your front matter includes this:
type:
- post
- posts
But I don't think that type
is a list. Instead, I think you need to use one of the following:
type: post
type: posts
¹ The other Hugo faq is about Hugo bundles and index.md
vs _index.md
…
Upvotes: 4