第一篇正式博文,我想給你們分享下個人博客的建立過程吧!⭐️git
Hugo 是由 Go 語言實現的靜態網站生成器。簡單、易用、高效、易擴展、快速部署。程序員
官方教程 英文github
Mac 安裝方式post
brew install hugo網站
hugo versionui
Windows 安裝方式spa
hugo version
查看版本
官方文檔教程,必看!code
新建 blog 目錄,運行 hugo new site xxx.github.io-generator
, xxx 爲 github 用戶名 。會在當前目錄中建立 xxx.github.io-generator 文件夾(博客生成器)server
進入博客生成器目錄,git init
blog
選擇並下載主題 ,放到 themes 目錄下 git clone https://github.com/dillonzq/LoveIt.git themes/LoveIt
遇到報錯 ↘
fatal: unable to access 'https://github.com/dillonzq/LoveIt.git/': error setting certificate verify locations:
CAfile: D:/Software/Git/mingw64/ssl/certs/ca-bundle.crt
CApath: none
複製代碼
解決辦法:使用 git clone 出現 fatal: unable to access 'https://github.com/...'
,執行代碼 ↓
git config --system http.sslverify false // 把證書校驗禁用
複製代碼
而後,將主題添加到站點配置中:echo 'theme = "LoveIt"' >> config.toml
// 主題目錄的名稱
建立新文章:hugo new posts/first_post.md
D:\blog\xxx.github.io-generator\content\posts\first_post.md
created
編輯文章後,修改 draft: false
。draft : true 表示處於草稿狀態,此時Hugo不會真正發佈它
初次建立博客或修改主題,需將主題文檔中給出的配置,粘貼到 config.toml
文件中。
baseURL 配置成 http://[用戶名].github.io/
hugo server -D
創建本地訪問 https://localhost:1313 預覽博客
hugo
建立一個新的目錄 public/,這就是須要提交到 github,最終生成線上博客的目錄
根目錄下,新建 .gitignore
文件,添加 /public/
。使得 /public 能夠自成一個倉庫
進入public cd public
,git init
git add .
git commit
[用戶名].github.io
。git remote add origin xxx
git push -u origin master
hugo new posts/第二篇博客.md
code posts/第二篇博客.md
對文件進行編輯,注意不要把文件本來的內容 front matter 給刪了,直接在後面另起一行寫新內容。hugo server -D
創建本地訪問 https://localhost:1313 預覽博客hugo -D
,獲得新的 public 目錄cd public
,執行一下操做
git add .
注意有一個點git commit -m update
git push -f
其中 -f 是強制上傳的意思
程序員永遠都會留備份
新建倉庫 xxx.github.io-generator
將本地 xxx.github.io-generator 目錄,git init
,git add .
,git commit -m backup
,git remote add origin xxx
,git push -u origin master
便可