如何添加新的hugo静态页面?
How to add a new hugo static page?
从 "getting started" 部分看来这应该有效,但实际上无效。
hugo new site my-site
hugo new privacy.md
hugo server --watch --includeDrafts
curl -L localhost:1313/privacy/index.html
# 404 page not found
curl -L localhost:1313/privacy.html
# 404 page not found
curl -L localhost:1313/privacy/
# 404 page not found
如何添加新页面?
刚刚在 Hugo 0.13 上测试正常:
hugo new site my-site
cd my-site
hugo new privacy.md
hugo server -w -D
curl -L localhost:1313/privacy/
注意:您必须使用主题或提供自己的布局模板才能获得比空白页更多的内容。当然,privacy.md 中的一些 Markdown 也会使它变得更好。
有关最新文档,请参阅 http://gohugo.io/overview/introduction。
这是如何在 Hugo 上创建静态 "landing pages" 的最佳教程:https://discuss.gohugo.io/t/creating-static-content-that-uses-partials/265/19?u=royston
基本上,您在 /content/
中创建 .md,在前文中使用 type: "page"
,然后为其创建自定义布局,例如在前文中创建 layout: "simple-static"
,然后创建布局模板在 themes/<name>/layouts/page/
中,例如 simple-static.html
。然后,像往常一样使用所有部分,并使用 {{ .Content }}
.
从原始 .md 文件中调用内容
我所有的静态(登陆)页面都使用这种方法。
顺便说一句,我没有使用 hugo new
,我只是克隆 .md 文件或将模板复制到 /content/
并使用我的 iA Writer 文本编辑器。但我也没有使用 Hugo server
,改编 npm-build-boilerplate 是 运行 服务器和构建。
我有类似的要求,添加静态页面(在本例中为 aboutus
)。以下步骤成功了,
- 创建了一个空文件
content/aboutus/_index.md
- 已创建 aboutus.html 页
layouts/section/aboutus.html
以"About"为例:
# will create content/about.md
hugo new about.md
编辑 about.md 并添加最后两行,metadata/front 问题如下:
title: "About"
date: 2019-03-26
menu: "main"
weight: 50
应该可以。
让你在 archetypes/default.md
中设置一些默认的 frontmatter
# archetypes/default.md
+++
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
+++
和 layouts/_default/single.html
中的单一布局来呈现一些变量或内容
# tags to render markdown content
<h1>{{ .Title }}</h1>
<p>{{ .Content }}</p>
<span>{{ .Params.date }}</span>
现在键入 hugo new privacy.md
,这将在 content/privacy.md
中的以下目录中创建一个新页面
从 "getting started" 部分看来这应该有效,但实际上无效。
hugo new site my-site
hugo new privacy.md
hugo server --watch --includeDrafts
curl -L localhost:1313/privacy/index.html
# 404 page not found
curl -L localhost:1313/privacy.html
# 404 page not found
curl -L localhost:1313/privacy/
# 404 page not found
如何添加新页面?
刚刚在 Hugo 0.13 上测试正常:
hugo new site my-site
cd my-site
hugo new privacy.md
hugo server -w -D
curl -L localhost:1313/privacy/
注意:您必须使用主题或提供自己的布局模板才能获得比空白页更多的内容。当然,privacy.md 中的一些 Markdown 也会使它变得更好。
有关最新文档,请参阅 http://gohugo.io/overview/introduction。
这是如何在 Hugo 上创建静态 "landing pages" 的最佳教程:https://discuss.gohugo.io/t/creating-static-content-that-uses-partials/265/19?u=royston
基本上,您在 /content/
中创建 .md,在前文中使用 type: "page"
,然后为其创建自定义布局,例如在前文中创建 layout: "simple-static"
,然后创建布局模板在 themes/<name>/layouts/page/
中,例如 simple-static.html
。然后,像往常一样使用所有部分,并使用 {{ .Content }}
.
我所有的静态(登陆)页面都使用这种方法。
顺便说一句,我没有使用 hugo new
,我只是克隆 .md 文件或将模板复制到 /content/
并使用我的 iA Writer 文本编辑器。但我也没有使用 Hugo server
,改编 npm-build-boilerplate 是 运行 服务器和构建。
我有类似的要求,添加静态页面(在本例中为 aboutus
)。以下步骤成功了,
- 创建了一个空文件
content/aboutus/_index.md
- 已创建 aboutus.html 页
layouts/section/aboutus.html
以"About"为例:
# will create content/about.md
hugo new about.md
编辑 about.md 并添加最后两行,metadata/front 问题如下:
title: "About"
date: 2019-03-26
menu: "main"
weight: 50
应该可以。
让你在 archetypes/default.md
# archetypes/default.md
+++
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
+++
和 layouts/_default/single.html
中的单一布局来呈现一些变量或内容
# tags to render markdown content
<h1>{{ .Title }}</h1>
<p>{{ .Content }}</p>
<span>{{ .Params.date }}</span>
现在键入 hugo new privacy.md
,这将在 content/privacy.md