自己搭建了一個博客用hugo,后因自己搭建的博客上傳文章,搞一些東西不方便,就創建了現在這個博客,不過還是把如何搭建hugo的過程記錄以下。
Ubuntu下的操作
1. 下載Git
打開終端 Ctrl+Alt+T 就可打開
下載Git
sudo apt update
sudo apt install git
設置用戶名和郵箱
git config --global user.name "zoey" git config --global user.email "zoey686@163.com"
查看設置的用戶名和密碼
git config --list
2.下載Hugo
方法一:
直接下載,一般hugo版本較低,在選擇theme(主題)的時候有一定限制
sudo apt install hugo
方法二:
wget https://github.com/gohugoio/hugo/releases/download/v0.54.0/hugo_0.54.0_Linux-64bit.deb sudo dpkg -i hugo_0.54.0_Linux-64bit.deb
檢查是否安裝好了hugo以及查看版本號
hugo --help
hugo version
3.建立博客
建立一個Git的文件夾
在文件夾里面建立myblog頁面存放博客頁面
mkdir gitFile hugo new site myblog
然后myblog下面就會有以下幾個文件夾自動生成
archetypes 文章開頭形式
content 內容
data 自定義模板
layouts 網頁模板文件
static 存儲圖片一些其他的資源
themes 主題
4.設置主題
進入themes文件然后克隆主題
首先去Hugo網站的thmem主題去選主題,要注意hugo的版本號
https://themes.gohugo.io/
進入網站選擇自己喜歡的主題
進入后會有克隆網址如下
如圖在終端輸入就設置好了主題
5.本地啟動博客
回到myblog文件下
cd ..
pwd
生成頁面
hugo server -t ezhil --buildDrafts
ezhil是theme的名字
然后會生存一個localhost:XXXXX
點進去或者復制到網頁 就可以看到為們的博客
6.搭載到服務器上
我是直接放在github上面
首先去github上新建一個repository,點擊new
輸入網站名稱,必須和你github的名稱一樣,再加上“.github.io“
直接輸入如下命令
hugo --theme=ezhil --baseUrl="http://zoey686.github.io/" --buildDrafts cd public git init git add . git comment -m "first my blog" git remote add origin https://github.com/zoey686/zoey686.github.io.git /* 如果說 origin存在 git remote rm origin */ git push /*
沒有push成功的話 git push -u origin master */
然后我們就可以通過zoey686.github.io進行訪問我們搭建的網站了