我对 Hugo 还很陌生,并试图通过文档和其他东西来理解它。我正在创建一个简单的
shortcode
,我想将其包含在我的页面中,但由于某种原因,短代码根本没有在我的页面中呈现。
以下是我的简码:
layouts\shortcodes\plain.html
:
{{ .Page.File.Ext }}
{{ . }}
{{ .Get "title" }}
{{ .Get "linkTitle" }}
<div>
{{ .Inner }}
</div>
以下是我要添加到 HTML 页面的内容:
\content\en\_index.html
:
+++
title = "Home-Test"
linkTitle = "Home-Test"
+++
{{< plain >}}
<h1>HELLO FROM BLOCKS SHORTCODES</h1>
{{< /plain >}}
以下是我的index.html,来自baseof
layouts\_default\baseof.html
:
<!doctype html>
<html lang="{{ .Site.Language.Lang }}" class="no-js">
<head>
{{ partial "head.html" . }}
</head>
<body>
{{ partial "loader.html" . }}
<header>
{{ partial "navbar.html" . }}
</header>
<main>
{{ block "plain" . }}{{ end }}
</main>
<footer>
{{ partial "footer.html" . }}
</footer>
{{ partialCached "scripts.html" . }}
</body>
</html>
我希望我提供的内容
<h1>HELLO FROM BLOCKS SHORTCODES</h1>
应该显示在Hugo渲染的HTML页面上,但它没有显示。有人可以纠正我我在这里做错了什么吗?
这个:
{{ block "plain" . }}{{ end }}
应该是:
{{ .Content }}