Hugo
主流靜態博客框架
搭建個人博客肯定會用到"靜態博客框架",比較主流的有Hexo與Hugo。
Hexo是一款基于Node.js的靜態博客框架。
Hugo是由Go語言實現的靜態網站生成器。
相對而言Hugo更簡單、易用部署快速。
這里對Hugo框架搭建與使用做簡單介紹。
Hugo搭建流程(Mac):
1.Mac基于brew工具,命令行直接安裝(Mac需要安裝好Homebrew包管理工具):
brew install hugo
(裝后驗證是否安裝成功:hugo version)
2.用hugo生成博客:
hugo new site myblog
(生成myblog名稱文件夾)
3.配置博客主題:(https://themes.gohugo.io/ 在主題網站挑選后 按主題提示下載)
舉例:
mkdir themes // Creates a Themes Folder
cd themes // Points to the Themes Folder
git submodule add https://github.com/pacollins/hugo-future-imperfect-slim.git
4.在本地啟動個人博客:
hugo server -t xx(主題名稱) --buildDrafts
----------------
// 舉例: 可以在下面提示地址本地瀏覽博客樣式
? MyBlog hugo server -t noteworthy --buildDrafts
| EN
+------------------+----+
Pages | 10
Paginator pages | 0
Non-page files | 0
Static files | 88
Processed images | 0
Aliases | 1
Sitemaps | 1
Cleaned | 0
Built in 58 ms
Watching for changes in /Users/wangxiaokang/wxk/MyBlog/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /Users/wangxiaokang/wxk/MyBlog/config.toml
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:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
5.創建并編寫文章:(編輯blog.md文件)
hugo new post/blog.md
6.編輯文章后重新部署文章:(同第四步驟指令)
hugo server -t xx(主題名稱) --buildDrafts
7.將個人博客部署到遠端服務器,部署到GitHub為例:
登錄GitHub創建倉庫 名稱:xxx(用戶名).github.io
8.關聯遠端倉庫:
hugo --theme=xx(主題) --baseUrl="https://xxx.github.io/" --buildDrafts
9.關聯配置完成后,使用git命令把本地Myblog文件推到github就完成了。
預覽搭建完成后的博客:https://wangxiaokangk.github.io/