【问题标题】:Modify index.html in hugo修改hugo中的index.html
【发布时间】:2018-03-26 04:36:55
【问题描述】:

我刚刚开始学习 hugo 快速入门教程。

查看here,这表明我应该能够通过创建 _index.md 文件来修改 home/default/root index.html。

$ hugo new site quickstart
Congratulations! Your new Hugo site is created in ~/quickstart.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

好,我们试试修改首页吧!

[~/quickstart]$ hugo new index.md
[~/quickstart/content/index.md created

[~/quickstart]$ hugo new _index.md
[~/quickstart/content/_index.md created

我已经编辑了这两个,大意是:

---
title: "Welcome"
date: 2017-10-13T20:31:39-05:00
draft: false
---

# This is a website!

Why nothing appears?

但是当我跑步时

[~/quickstart]$ hugo server -D
Started building sites ...

Built site for language en:
0 draft content
0 future content
0 expired content
1 regular pages created
6 other pages created
0 non-page files copied
0 paginator pages created
0 tags created
0 categories created
total in 5 ms
Watching for changes in ~/quickstart/{data,content,layouts,static}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

我看到了,没有内容:

我还有什么需要做的吗?构建或降价或渲染步骤或其他什么?

【问题讨论】:

    标签: go static-site hugo


    【解决方案1】:

    您不需要 index.md,但确实需要 _index.md。你可以删除它。

    在您的布局文件夹中创建一个名为index.html 的文件。那是站点根页面的模板 html 文件。现在添加您的基本样板文档/html 标记。这允许服务器注入 Javascript 自动重新加载脚本。现在刷新您的浏览器以获取脚本。

    现在你可以开始玩了。在 body 标签中添加 {{.Title}} 并观察浏览器更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多