新規作成したい(hugo new
)
$ hugo new site サイト名
$ tree サイト名
サイト名
├── archetypes
│ └── default.md
├── assets
├── content
├── data
├── hugo.toml
├── i18n
├── layouts
├── static
└── themes
hugo new site
コマンドでHugoサイトのスケルトンを作成せきます。
プロジェクトを初期化したときのディレクトリ構造は上記のとおりです。
それぞれのファイル/ディレクトリの役割を以下に整理しました。
ディレクトリ名 |
ファイル形式 |
役割 |
---|---|---|
|
|
全体設定ファイル。( |
|
|
コンテンツを新規作成するときのスケルトンを配置 |
|
|
Hugo Pipesなどを使って前処理が必要なファイルを配置 |
|
|
コンテンツファイルを配置 |
|
|
データファイルを配置 |
|
|
多言語サイト用。言語ごとの翻訳ファイルを配置 |
|
|
テンプレートファイルを配置 |
|
|
画像やCSS/JSなどの静的ファイルを配置 |
|
- |
外部テーマを配置 |
全体を設定するファイルはhugo.toml
です。
これはconfig/_default/hugo.toml
に移動させます。
themes
以下に外部テーマをインストールできます。
Hugo Themesなどから探してみましょう。
GitHubなどで公開されているテーマは、Gitサブモジュールでインストールするのがよいです。
layouts
にはテンプレートファイルを配置します。
テンプレートはGoテンプレート言語を使って記述します。
外部テーマを部分的に修正したいときは、ここに同じ名前のファイルを作成することで、レンダリング結果を上書きできます。
コンテンツしたい(hugo new content
)
$ cd サイト名
$ hugo new content セクション/コンテンツ.md
$ cat content/セクション/コンテンツ.md
hugo new content
コマンドでコンテンツのスケルトンを作成できます。
テーマしたい(hugo new theme
)
$ cd サイト名
$ hugo new theme テーマ名
$ cd themes/テーマ名
$ tree
tree
.
├── LICENSE
├── README.md
├── archetypes
│ └── default.md
├── assets
│ ├── css
│ │ └── main.css
│ └── js
│ └── main.js
├── content
│ ├── _index.md
│ └── posts
│ ├── _index.md
│ ├── post-1.md
│ ├── post-2.md
│ └── post-3
│ ├── bryce-canyon.jpg
│ └── index.md
├── data
├── hugo.toml
├── i18n
├── layouts
│ ├── _default
│ │ ├── baseof.html
│ │ ├── home.html
│ │ ├── list.html
│ │ └── single.html
│ └── partials
│ ├── footer.html
│ ├── head
│ │ ├── css.html
│ │ └── js.html
│ ├── head.html
│ ├── header.html
│ ├── menu.html
│ └── terms.html
├── static
│ └── favicon.ico
└── theme.toml
hugo new theme
コマンドでテーマのスケルトンを作成できます。