本身搭建了一個博客用hugo,後因本身搭建的博客上傳文章,搞一些東西不方便,就建立了如今這個博客,不過仍是把如何搭建hugo的過程記錄如下。git
Ubuntu下的操做github
1. 下載Git服務器
打開終端 Ctrl+Alt+T 就可打開網站
下載Gitui
sudo apt update
sudo apt install git
設置用戶名和郵箱spa
git config --global user.name "zoey" git config --global user.email "zoey686@163.com"
查看設置的用戶名和密碼code
git config --list
2.下載Hugoserver
方法一:blog
直接下載,通常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進行訪問咱們搭建的網站了