2017-10-14 73 views
0

我剛剛開始學習hugo快速入門教程。修改hugo中的index.html

尋找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 

我看到這一點,沒有任何內容:

Blank screen

是還有什麼我需要做的?構建或降價或渲染步驟或什麼?

回答

1

你不需要index.md,但你確實需要_index.md。你可以刪除它。

在您的佈局文件夾中創建一個名爲index.html的文件。這是您網站根頁面的模板html文件。現在添加您的基本樣板文件/ html標記。這允許服務器注入一個Javascript自動重載腳本。現在刷新您的瀏覽器以獲取腳本。

現在你已經準備好玩了。在body標籤中添加{{.Title}}並觀看瀏覽器更新。