惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
博客园_首页
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
G
Google Developers Blog
博客园 - 司徒正美
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 叶小钗
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN Mintty Tips and Configurations
Content inside HTML tags missing in Latest Hugo?
2019-12-29 · via jdhao's digital space

Due to Markdown’s inability to center and resize image properly, I use the raw HTML tags inside markdown file to include images:

由于 Markdown 格式无法很好居中和设定图像尺寸,我使用 HTML tags 来添加图像(图像可以很好居中以及设定显示大小):

<p align="center">
<img src="xxx.xx.xx/test.jpg">
</p>

Recently, after updating to Hugo version 0.62, I found that all the images using HTML tags are missing in the generated HTML files.

最近,升级了 Hugo 0.62 版本以后,我发现所有使用 HTML tag 引入的图像在生成的最终 HTML 文件中都消失了。

I checked the generated HTML source file for my post, and found that the raw HTML tag for image is rendered as the following comment tag:

我查看了某个博文渲染而成的 HTML 源文件,发现 Markdown 中的 HTML 图像 tag 被渲染成了 HTML 中的注释:

<!-- raw HTML omitted -->

After a little dig, I find out the cause. Previously, Hugo was using Blackfriday to render Markdown files. Since Hugo version 0.60, the default Markdown renderer has been changed to goldmark. In goldmark, the default behaviour is not to render raw HTML tags.

经过一番查找,我找了问题的原因。在之前的版本中(0.60 版本之前),Hugo 使用 Blackfriday 来渲染 Markdown 文件。从 0.60 版本开始,默认的 Markdown 渲染器已经改成了 goldmark。Goldmark 渲染器默认不回渲染 HTML tags。

To fix this issue, we have two options. First option, set blackfriday as the default Markdown engine. Open config.toml and add the following setting:

为了修复这个问题,我们有两种不同的解决方法。第一种选择,重新把 blackfriday 设定为默认的 Markdown 引擎。打开 config.toml,加入以下设定:

[markup]
  defaultMarkdownHandler = "blackfriday"

Second option, use goldmark and set the unsafe option of markup.goldmark.renderer to true:

第二种方式,使用 goldmark 引擎,加入以下设定,更改 goldmark 默认行为:

[markup]
  defaultMarkdownHandler = "goldmark"
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true

References#