HUGO ja 非公式

  • ニュース
  • ドキュメント
  • テーマ
  • コミュニティ
  • GitHub
gohugoio Star づけ
  暫定公開中 2024/09/16 (94d7f576a 対応, 2024/09/15)
  • Hugo について
    • 本節
    • Introduction
    • Hugo の機能
    • Privacy
    • セキュリティ
    • ライセンス
  • インストール
    • 本節
    • macOS
    • Linux
    • Windows
    • BSD
  • はじめよう
    • 本節
    • クイックスタート
    • ディレクトリ構造
    • 基本操作
    • 設定
    • Configure markup
    • 用語集
    • 本書以外の学習リソース
  • クイックリファレンス
    • 本節
    • Emojis
    • Functions
    • Methods
    • Page collections
  • コンテント管理
    • 本節
    • コンテントの構成
    • ページバンドル
    • コンテントフォーマット
    • フロントマター
    • ビルドオプション
    • ページリソース
    • イメージ処理
    • ショートコード
    • 関連コンテント
    • Sections
    • Content types
    • アーキタイプ
    • 分類
    • Summaries
    • Links and cross references
    • URL 管理
    • メニュー
    • コメント
    • マルチ言語
    • Markdown attributes
    • シンタックスハイライト
    • Diagrams
    • Mathematics
    • Data sources
    • Content adapters
  • テンプレート
    • 本節
    • はじめに
    • Template types
    • Lookup order
    • 基本テンプレート
    • Home templates
    • Single templates
    • Section templates
    • Taxonomy templates
    • Term templates
    • 部分テンプレート
    • コンテントビューテンプレート
    • ショートコードテンプレート
    • サイトマップテンプレート
    • RSS テンプレート
    • 404 テンプレート
    • robots.txt templates
    • メニュー
    • ページネーション
    • Embedded templates
    • Custom output formats
  • 関数
    • 本節
    • cast
    • collections
    • compare
    • crypto
    • css
    • data
    • debug
    • diagrams
    • encoding
    • fmt
    • global
    • go template
    • hash
    • hugo
    • images
    • inflect
    • js
    • lang
    • math
    • openapi3
    • os
    • partials
    • path
    • reflect
    • resources
    • safe
    • strings
    • templates
    • time
    • transform
    • urls
  • メソッド
    • 本節
    • Duration
    • Menu
    • Menu entry
    • Page
    • Pager
    • Pages
    • Resource
    • Shortcode
    • Site
    • Taxonomy
    • Time
  • レンダーフック
    • 本節
    • Introduction
    • Blockquotes
    • Code blocks
    • Headings
    • Images
    • Links
    • Passthrough
    • Tables
  • Hugo モジュール
    • In this section
    • Configure Hugo modules
    • Use Hugo Modules
    • Theme components
  • Hugo パイプ
    • 本節
    • Introduction
    • Transpile Sass to CSS
    • PostCSS
    • PostProcess
    • JavaScript building
    • Babel
    • Asset minification
    • Concatenating assets
    • Fingerprinting and SRI hashing
    • Resource from string
    • Resource from template
  • CLI
  • トラブルシューティング
    • 本節
    • Logging
    • Inspection
    • Deprecation
    • Performance
    • FAQs
  • 開発ツール
    • 本節
    • Editor plugins
    • Front-ends
    • 検索
    • Migrations
    • Other projects
  • ホスティングと開発
    • 本節
    • Hugo Deploy
    • Deploy with Rclone
    • Deploy with Rsync
    • Host on 21YunBox
    • Host on AWS Amplify
    • Host on Azure Static Web Apps
    • Host on Cloudflare Pages
    • Host on Firebase
    • Host on GitHub Pages
    • Host on GitLab Pages
    • Host on KeyCDN
    • Host on Netlify
    • Host on Render
  • 貢献
    • 本節
    • Development
    • ドキュメント
    • Themes
  • メンテナンス

クイックスタート

ほんの数分で Hugo サイト生成方法を学びます。

本チュートリアルでは以下を行います。

  1. サイトの生成
  2. コンテントの追加
  3. サイトの設定
  4. サイトの公開

前提条件

チュートリアルをはじめる前には、以下の作業が必要です。

  1. Hugo のインストール (拡張エディション、v0.112.0 またはそれ以降)
  2. Git のインストール

またコマンドライン操作にも慣れておく必要があります。

サイトの生成

コマンド

Windows ユーザーの場合

  • コマンドプロンプトは利用しないでください。
  • Windows PowerShell は利用しないでください。
  • Run these commands from PowerShell or a Linux terminal such as WSL or Git Bash

PowerShell と Windows PowerShell は異なるアプリケーションです。

以下を実行して Hugo のバージョンが v0.112.0 またはそれ以降であることを確認してください。

hugo version

以下のコマンドを実行して、Ananke テーマを用いた Hugo サイトの生成を行います。 各コマンドの説明は次の節で示します。

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo "theme = 'ananke'" >> hugo.toml
hugo server

端末画面に示されている URL にアクセスしてサイトを確認します。 Ctrl + C を押下すれば Hugo の開発用サーバーを停止させることができます。

各コマンドの説明

quickstart ディレクトリ配下に、プロジェクト用の ディレクトリ構造 を作り出します。

hugo new site quickstart

カレントディレクトリをプロジェクトのルートとします。

cd quickstart

カレントディレクトリにおいて、空の Git リポジトリを初期化します。

git init

Ananke テーマをクローンして themes ディレクトリに置きます。 追加にあたっては、プロジェクトに対して Git サブモジュール として追加します。

git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

サイト設定ファイルに以下の 1 行を追加します。 カレントなテーマを設定するものです。

echo "theme = 'ananke'" >> hugo.toml

Hugo の開発用サーバーを起動して、サイトの確認を行います。

hugo server

Ctrl + C を押下すれば Hugo の開発用サーバーを停止することができます。

コンテントの追加

サイトに対して新規のページを追加します。

hugo new content content/posts/my-first-post.md

Hugo は content/posts ディレクトリに新たなファイルを生成します。 テキストエディターを使って、そのファイルを開いてみます。

+++
title = 'My First Post'
date = 2024-01-14T07:07:07+01:00
draft = true
+++

なお フロントマター における draft の値は true としています。 Hugo ではサイトビルド時にドラフト (draft) コンテントは公開しないものとなっています。 詳しくは ドラフト、公開予定、期限切れのコンテント を参照してください。

ポスト (post; 投稿内容) の本文に マークダウン を適当に追加します。 ただし draft の値はそのままとします。

+++
title = 'My First Post'
date = 2024-01-14T07:07:07+01:00
draft = true
+++
## はじめに

これは **ボールド体** のテキストです。これは *強調体* のテキストです。

[Hugo](https://gohugo.io) のウェブサイトを参照してください!

ファイルを保存し、Hugo の開発用サーバーを起動してサイトを確認します。 以下のいずれかのコマンドを実行すれば、ドラフトコンテントであっても表示されることになります。

hugo server --buildDrafts
hugo server -D

端末画面に示されている URL にアクセスしてサイトを確認します。 コンテントの追加や変更を行う場合には、開発用サーバーを起動したままとします。

When satisfied with your new content, set the front matter draft parameter to false.

Hugo のレンダリングエンジンは、マークダウンに関しては CommonMark の仕様 に準拠しています。 CommonMark では、リファレンス実装 (reference implementation) に基づいた、便利な オンライン確認ツール を提供しています。

サイトの設定

テキストエディターを使って、プロジェクトルートにある サイト設定ファイル (hugo.toml) を開きます。

baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = 'ananke'

これを以下のように変更します。

  1. 本番サイト用の baseURL を設定します。 設定する値は上で示しているように、プロトコルを必ず先頭につけ、最後にはスラッシュをつけます。

  2. languageCode に利用する言語と地域を設定します。

  3. 本番サイト用の title を設定します。

Hugo の開発用サーバーを起動して変更箇所を確認します。 ドラフトコンテントも表示する起動とすることを忘れないでください。

hugo server -D

提供されるテーマにおいては、たいていは設定ガイドラインやオプションが提供されています。 詳しいことは、そのテーマのリポジトリやドキュメントサイトを参照してください。

The New Dynamic, authors of the Ananke theme, provide documentation for configuration and usage. They also provide a demonstration site.

サイトの公開

In this step you will publish your site, but you will not deploy it.

When you publish your site, Hugo creates the entire static site in the public directory in the root of your project. This includes the HTML files, and assets such as images, CSS files, and JavaScript files.

When you publish your site, you typically do not want to include draft, future, or expired content. The command is simple.

hugo

To learn how to deploy your site, see the hosting and deployment section.

Ask for help

Hugo’s forum is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about requesting help before asking your first question.

Other resources

For other resources to help you learn Hugo, including books and video tutorials, see the external learning resources page.

関連項目

  • BSD
  • Development
  • GitInfo
  • Host on 21YunBox
  • Host on GitHub Pages

このページ内

  • 前提条件
  • サイトの生成
  • コンテントの追加
  • サイトの設定
  • サイトの公開
  • Ask for help
  • Other resources
最終更新日付: 0001/01/01
ページの変更
Hugo 作者より
Hugo Logo
  • Issue 報告
  • ヘルプ
  • @GoHugoIO
  • @spf13
  • @bepsays
 

Hugo Sponsors

Route4Me
Your Company?
 

The Hugo logos are copyright © Steve Francia 2013–2024.

The Hugo Gopher is based on an original work by Renée French.

  • ニュース
  • ドキュメント
  • テーマ
  • コミュニティ
  • GitHub
  • Hugo について
  • インストール
  • はじめよう
  • クイックリファレンス
  • コンテント管理
  • テンプレート
  • 関数
  • メソッド
  • レンダーフック
  • Hugo モジュール
  • Hugo パイプ
  • CLI
  • トラブルシューティング
  • 開発ツール
  • ホスティングと開発
  • 貢献
  • メンテナンス