安裝後可以檢查是否安裝成功,順便檢查版本號,目前安裝的 Hugo 版本為 v0.120.4,Git 為 v2.43.0
1
2
3
4
5
wells@server:~/wellwells_hugo$ hugo version
hugo v0.120.4-f11bca5fec2ebb3a02727fb2a5cfb08da96fd9df+extended linux/amd64 BuildDate=2023-11-08T11:18:07Z VendorInfo=snap:0.120.4
wells@server:~/wellwells_hugo$ git --version
git version 2.43.0
開始新的網站
在一個可以存放網誌原始檔的地方,Linux 可選擇個人的 Home 目錄(~/),Windows 可選擇使用者目錄(C:\Users\USER),想儲存在其他區域也是都可以的,要開始新的網站,輸入 hugo new site BLOG_NAME,並進入到該目錄即可,這邊以 my_blog 為例子:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
wells@server:~$ hugo new site my_blog
Congratulations! Your new Hugo site was created in /home/wells/my_blog.
Just a few more steps...
1. Change the current directory to /home/wells/my_blog.
2. Create or install a theme:
- Create a new theme with the command "hugo new theme <THEMENAME>"
- Install a theme from https://themes.gohugo.io/
3. Edit hugo.toml, setting the "theme" property to the theme name.
4. Create new content with the command "hugo new content <SECTIONNAME>/<FILENAME>.<FORMAT>".
5. Start the embedded web server with the command "hugo server --buildDrafts".
See documentation at https://gohugo.io/.
wells@server:~$ cd my_blog/
wells@server:~/my_blog$ ls # 列出目錄結構
archetypes assets content data hugo.toml i18n layouts static themes
wells@server:~/my_blog$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/wells/my_blog/.git/
wells@server:~/my_blog$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.hugo_build.lock
archetypes/
hugo.toml
nothing added to commit but untracked files present (use "git add" to track)
wells@server:~/my_blog$ git add archetypes/ hugo.toml
wells@server:~/my_blog$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: archetypes/default.md
new file: hugo.toml
Untracked files:
(use "git add <file>..." to include in what will be committed)
.hugo_build.lock
安裝 Hugo 主題
要安裝 Hguo 主題,我們可以先到 Hugo Themes 找一個喜歡的主題,主題的供應者會提供安裝的方式。
wells@server:~/my_blog$ hugo server -D
port 1313 already in use, attempting to use an available port
Watching for changes in /home/wells/my_blog/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in /home/wells/my_blog/hugo.yaml
Start building sites …
hugo v0.120.4-f11bca5fec2ebb3a02727fb2a5cfb08da96fd9df+extended linux/amd64 BuildDate=2023-11-08T11:18:07Z VendorInfo=snap:0.120.4
| ZH-TW
-------------------+--------
Pages | 10
Paginator pages | 0
Non-page files | 0
Static files | 0
Processed images | 0
Aliases | 2
Sitemaps | 1
Cleaned | 0
Built in 25 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:46651/ (bind address 127.0.0.1)
Press Ctrl+C to stop