我用过 hugo-icon单页主题构建静态站点,并被要求添加新页面用于产品描述。我已经阅读了堆栈上的许多教程/答案并观看了 Mike Danes videos到目前为止,但无法获取新页面来呈现。
当我运行以下命令hugo new products/product1/_index.md
时,会生成product1的url,但不会呈现任何内容。这是我的 _index.md 文件的内容;
---
title: "Product1"
date: 2021-05-24T14:47:36+01:00
draft: false
---
product1 info
我期望以下两件事之一;查看 url 上呈现的“product1 信息”。或者我在文件夹结构中的某个位置放置了一个同名的 html 文件来呈现文本等。我已经尝试了多个位置来放置 html,但仍然看不到任何内容。
有人可以解释或举一个向hugo-icon主题添加新页面的示例,并解释我是否缺少基本概念。
配置:
# Main config file for icon theme.
theme = ["hugo-icon"]
baseURL = "https://www.example.com/"
languageCode = "en-ie"
title = "my site"
[params]
author = "Me"
description = "My site"
# Hero section (from here on is for icon theme)
[params.hero]
img = "images/hero_bg_green.jpg"
title = "My Site"
谢谢
最佳答案
我错过了这个基本的设计模式。在布局下创建的每个文件夹都需要一个模板。在我的例子中,它看起来如下所示,其中每个页面都是在 single.html 文件内设计的
Layouts
page1
single.html
page2
single.html
路由需要在 content/pages/page-one.md 内的内容文件夹中定义,如下所示,其中类型通过其类型定义映射到文件夹名称
type : "page1"
title: "Page 1"
date: 2021-05-27T11:16:39+01:00
draft: false
因此我的网址是 www.example.com/pages/page-one.html它在layouts/page1/single.html中设计并通过类型定义映射到 www.example.com/content/pages/page-one.md
content/... 中的 .md 文件指示 url 的路径。类型定义指示从布局/...渲染哪个页面
关于Hugo 内容未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67673384/