HUGO 是一套模版靜態化的系統,瞭解其目錄結構有助於創建我們的網站系統
目錄結構
以Hyde主題為例,完整的目錄結構如下:
iChochy
├── archetypes 內容模版目錄
│ └── default.md 模版文件
├── config.toml 配置文件
├── content 內容目錄
├── data 數據目錄
├── layouts 網站模版目錄
├── static 靜態文件目錄
└── themes 主題目錄
└── hyde Hyde主題目錄
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── archetypes 內容模版
│ └── default.md
├── go.mod
├── images
│ ├── screenshot.png
│ └── tn.png
├── layouts 網站模版
│ ├── 404.html 404面目模版
│ ├── _default 默認模版目錄
│ │ ├── baseof.html 基礎模版
│ │ ├── list.html 列表頁面模版
│ │ └── single.html 單頁面模版
│ ├── index.html 首頁模版
│ └── partials 模塊模版目錄
│ ├── head.html HEAD模塊模版
│ ├── head_fonts.html
│ ├── hook_head_end.html
│ └── sidebar.html
├── static 靜態目錄
│ ├── apple-touch-icon-144-precomposed.png
│ ├── css
│ │ ├── hyde.css
│ │ ├── poole.css
│ │ ├── print.css
│ │ └── syntax.css
│ └── favicon.png
└── theme.toml 主題配置文件
archetypes
內容模版目錄,通過內容模版,使用hugo new命令創建新的內容文件
default.md 內容模版
---
title: ”{{ replace .Name “-” “ ” | title }}“
date: {{ .Date }}
categories:
- iChochy
tags:
- iChochy
---
使用命令:hugo new posts/iChochy.md,生成內容文件 content/posts/iChochy.md
---
title: ”iChochy“
date: 2020-08-10T18:13:25+08:00
categories:
- iChochy
tags:
- iChochy
---
config.toml
項目的配置文件,列舉些常用的參數。如下:
# 基礎參數,通過.Site.xxxx獲取參數
# 網站標題
title = ”回憶中的明天“
# 域名地址
baseURL = ”https://ichochy.com/“
# 主題名稱
theme = ”hyde“
# 網站的語言代碼
languageCode = ”zh_CN“
# 啓用以將相對URL變為絕對URL
canonifyURLs = false
# Hugo 生成靜態站點的目錄
publishDir = ”docs“
# 啓用生成robots.txt文件
enableRobotsTXT = false
# 啓用自動檢測內容中的中文/日語/韓語,讓.Summary和.WordCount對於CJK語言正確運行
hasCJKLanguage = false
# 指定.Summary 的長度
summaryLength = 70
# 默認分頁數
paginate = 10
# 啓用.html後綴地址,默認URL為/filename/,啓用為/filename.html
uglyurls = false
# 自定義參數,通過.Site.Params.xxxx獲取參數
[params]
postDir = ”posts“
layoutReverse = false
copyright = ”iChochy“
description = ”碼農小站,寫點Java、Swift和感悟“
# 菜單參數,通過.Site.Menus.main獲取參數
# Name為菜單名稱、Weight為菜單排序參數、URL為菜單名稱
[Menus]
main = [
{Name = ”Categories“, Weight = 1, URL = ”/categories/“},
{Name = ”Tags“, Weight = 2, URL = ”/tags/“},
{Name = ”Links“, Weight = 3, URL = ”/links/“},
{Name = ”About“, Weight = 4, URL = ”/about/“},
{Name = ”Feedback“, Weight = 5, URL = ”/feedback/“}
]
content
內容目錄,網站的MD源文件,通過對應的模版生成靜態文件
data
數據目錄,存儲結構數據,可以用YAML,JSON或TOML格式編寫數據文件,可用.Site.Data.xxxx的方式來獲取數據
layouts
模版目錄,以.html文件形式存儲模板,這些模板指定如何將內容目錄中的源文件呈現到靜態網站中
模版包括:主頁模版、單頁模板、列表模版、分類模版、模塊模版等
static
靜態文件目錄,存儲所有靜態內容,如:Image,CSS,JavaScript等
當Hugo建立您的網站時,靜態目錄內的所有文件均按原樣複製生成,可有來存儲效驗文件、CNAME文件等
相關文章
-
免費創建屬於自己的博客,Hugo+Github Pages 2020/08/02
-
jekyll-admin的搭建和使用 2019/09/25
-
加速你的博客永無止境-七牛雲存儲2019/03/08
-
加速你的博客永無止境-七牛雲CDN2019/03/06
源文:https://ichochy.com/posts/20200810.html