Website

Hugo - 資料夾結構


Hugo’s CLI scaffolds a project directory structure and then takes that single directory and uses it as the input to create a complete website. Running the hugo new site generator from the command line will create a directory structure with the following elements:
.
├── archetypes
├── config.toml
├── content
├── data
├── layouts
├── static
└── themes

大致意思是Hugo的命令列介面由一個專案資料夾結構所架構,利用單一資料夾當成輸入來創造一個完整網站。
執行命令行 hugo new site 將產生資料夾結構包含下列:

archetypes

You can create new content files in Hugo using the hugo new command. By default, Hugo will create new content files with at least date, title (inferred from the file name), and draft = true. This saves time and promotes consistency for sites using multiple content types. You can create your own archetypes with custom preconfigured front matter fields as well.

你可以使用 hugo new 來創立新的內容文件。預設產生新的內容文件包含至少日期、標題、草稿(設定true),這將節省時間並為使用多種內容類型的網站提高一致性。創造屬於您的原型(自定義預配置的前台設定)。

assets

Stores all the files which need be processed by Hugo Pipes. Only the files whose .Permalink or .RelPermalink are used will be published to the public directory. Note: assets directory is not created by default.

此資料夾存放Hugo Pipes需要被處理的所有檔案,只有檔案的 .Permalink.RelPermalink被使用時將會被發佈至public目錄。
(預設是不會創建assets資料夾)

config

Hugo ships with a large number of configuration directives. The config directory is where those directives are stored as JSON, YAML, or TOML files. Every root setting object can stand as its own file and structured by environments. Projects with minimal settings and no need for environment awareness can use a single config.toml file at its root.

Many sites may need little to no configuration, but Hugo ships with a large number of configuration directives for more granular directions on how you want Hugo to build your website. Note: config directory is not created by default.

Hugo附帶大量配置指令,config資料夾裡頭的指令存放JSON, YAML, 或TOML檔案。每個根設定對象都可作為自己的文件並按照環境構建。專案具有最少的設置且不需要環境意識可以在根目錄下使用單一config.toml。 許多網站可能幾乎不需要設置,Hugo附帶大量配置指令在於您想要Hugo如何建構網站提供更詳細的方向。
(預設是不會創建config資料夾)

content

All content for your website will live inside this directory. Each top-level folder in Hugo is considered a content section. For example, if your site has three main sections—blog, articles, and tutorials—you will have three directories at content/blog, content/articles, and content/tutorials. Hugo uses sections to assign default content types.

網站的所有內容將位於此目錄,每個頂層的資料夾被視為內容的區塊,例如你的網站有三個主要分區(blog, articles, tutorials),你將有三個目錄(content/blog, content/articles, content/tutorials)。Hugo使用分區來指定預設的內容型態。

data

This directory is used to store configuration files that can be used by Hugo when generating your website. You can write these files in YAML, JSON, or TOML format. In addition to the files you add to this folder, you can also create data templates that pull from dynamic content.

此目錄被用於儲存Hugo在生成網站時可以使用的配置檔,可以使用YAML, JSON,或 TOML格式來編寫這些文件。除了將配置檔添加到此目錄之外,也可以創建從動態內容中提取的數據模板。

layouts

Stores templates in the form of .html files that specify how views of your content will be rendered into a static website. Templates include list pages, your homepage, taxonomy templates, partials, single page templates, and more.

以.html文件形式儲存樣板,並指定如何將內容呈現成一個靜態網站中。樣板包含列表頁面、主頁、、分類樣板、、部分樣板、單頁樣板等。

static

Stores all the static content: images, CSS, JavaScript, etc. When Hugo builds your site, all assets inside your static directory are copied over as-is. A good example of using the static folder is for verifying site ownership on Google Search Console, where you want Hugo to copy over a complete HTML file without modifying its content. From Hugo 0.31 you can have multiple static directories.

儲存所有靜態內容:影像、CSS、JavaScript等。。當Hugo建立網站時,在靜態目錄底下所有資產都會按原樣複製。使用靜態目錄很好的例子就是Google Search Console的驗證網站擁有權,在此你要Hugo複製完整Html檔案而不做任何修改。
從Hugo 0.31開始,可以擁有多個static資料夾。

resources

Caches some files to speed up generation. Can be also used by template authors to distribute built SASS files, so you don’t have to have the preprocessor installed. Note: resources directory is not created by default.

快取一些檔案來加速生成,樣板作者也可以用它來分散建立SASS檔案,所以你不必安裝預設處理器。
(預設是不會創建resources資料夾)

什麼是CLI?

Command-Line Interface 命令列介面

什麼是SASS?

Syntactically Awesome Stylesheets 疊層樣式表語言

Reference

官方網站 資料夾結構
Wiki CLI
Wiki SASS