Hugo博客文章标题中支持Markdown吗?

huangapple go评论68阅读模式
英文:

Markdown support in hugo blog post's title?

问题

Hugo有一个前置数据(front matter)部分,它支持TOML格式。

+++
date = "2016-11-15T09:36:44+05:30"
draft = true
title = "Grab it for <s>$100</s> $40"
+++

在这里,我使用<s>$100</s>来划掉$100,但是我无法在Hugo的文章中的前置数据部分实现相同效果。所以Hugo不支持在标题中使用Markdown吗?有没有任何解决方法?

英文:

Hugo has its front matter where it supports TOML format.

> +++
> date = "2016-11-15T09:36:44+05:30"
> draft = true
> title = "Grab it for <s>$100</s> $40"
> +++

Here I used &lt;s&gt;$100&lt;/s&gt; to strike through $100, but I am unable to do the same in hugo post, inside that front matter. So Hugo doesn't support markdown in title?, Is there any workaround for it?

答案1

得分: 5

你可以在生成标题的布局中使用以下代码:

{{ .Title | markdownify }}

通常可以在 layouts/ 目录下找到该布局文件。

英文:

You could use

{{ .Title | markdownify }}

in your layout that is generating the title. It is usually found at layouts/.

huangapple
  • 本文由 发表于 2016年11月15日 12:28:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/40602050.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定