javascript - Hugo 在帖子中使用内联 javascript
问题描述
当嵌入帖子中时,我无法让 Hugo 加载内联 javascript。我尝试导入的 javascript 是一个电子邮件注册表单。从其他示例来看,语法似乎是正确的。网站或主题中是否有任何设置会阻止 javascript 加载?
Hugo 版本:v0.74.1 主题:hello-friend-ng
邮政和前台事项
---
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>
谢谢!
解决方案
我认为这是 Hugo 世界中最常见的问题之一。¹从 Hugo v0.60.0 开始,默认的 Markdown 渲染器是Goldmark,Goldmark 默认忽略原始 HTML,例如<script ...
. 要使用原始 HTML,您需要在 config.toml 中指定如下内容:
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
我在我的Hugo Tips and Fragments中的片段 14 和 15中写到了这一点。
旁注:您的正面内容包括:
type:
- post
- posts
但我不认为这type
是一个清单。相反,我认为您需要使用以下方法之一:
type: post
type: posts
¹ 另一个 Hugo 常见问题是关于Hugo 捆绑包和index.md
vs _index.md
...</p>
推荐阅读
- java - 使用 spring SecurityWebFilterChain 如何禁用/阻止除少数已知路径外的所有非 https 请求
- c - 16 位 2 的补码中的否定错误
- java - 给定正确的 FilePath 时 createNewFile() 引发 FileNotFoundException
- firebase - Fluttter - [Firebase] 您的 Cloud Firestore 数据库有不安全的规则
- python - 无法在 python(Azure 函数)中将 azure.cognitiveservices.speech 导入为 Speechsdk 错误(分段错误(核心转储))
- r - 是否可以仅切割一排刻面的 y 轴?
- javascript - 由于 cdc_acm,WebUSB 访问被拒绝
- python - 创建新的 Conda 环境会与旧环境混淆?
- office-js - Microsoft O365 加载项“安装失败”
- django - 有什么方法可以覆盖 django.request 并更改 cookie 解析的逻辑?