Hugo 搭建筆記(二)

MorrisLin
Aug 29, 2022

--

在上一篇的分享中,我們搭建好了Hugo,現在要讓它可以上傳到github pages,讓大家可以看到你所搭建的網誌。

首先需要有Github帳號,然後建立新的repository

建立完後到自己的hugo目錄將專案建立remote 並push 上去

git remote add origin [你的repo]
git branch -M main
git add .
git commit -m "feat: add change"
git push -u origin main

成功後重新整理建立頁面就會出現專案

點擊右上角的setting > pages > 選取Branch > 在點擊save

在實作時遇到一個問題,在Actions的build中出現問題

這邊可以看到是themes/LoveIt/exampleSite/content/posts/theme-documentation-content/index.en.md 這邊有錯誤導致build失敗。

根據問題來看是jekyll,但在build hugo是不需要jekyll的,所以我們要換另外一個方式使actions使用hugo 方式部署。

選擇Github Actions 會發現有出現Hugo的選項,點擊Configure後會產生一個yml,這個是Github Actions build Hugo的設定檔,commit後就會開始自動build,成功後會在Github Pages中看到網址。

https://uranuslin.github.io/hugo-demo/

這樣就完成我們的首次部署Hugo到Github pages了,之後只要新增文章後commit > push origin main 就會自動部署更新網誌了。

--

--

MorrisLin
MorrisLin

Written by MorrisLin

Back-end engineer turn into Blockchain software engineer

No responses yet