基於Hugo搭建的個人博客

我的博客地址:https://enriqueliu.github.io/

一、Hugo下載安裝

由於github中下載的地址比較慢, 微雲分享 hugo_0.69.2_Windows-64bit
下載後解壓將 hugo.exe 的目錄添加到環境變量
檢查是否安裝——》打開powershell——》輸入"hugo version"
在這裏插入圖片描述

二、搭建博客

生成site目錄

打開powershell

hugo new site myblog

此時會生成

└─myblog
    ├─archetypes
    ├─content
    ├─data
    ├─layouts
    ├─static
    └─themes

config.toml是配置文件,自定義博客標題、地址等

選擇主題

前往 themes.gohugo.io 挑選自己喜歡的主題,下載後放到目錄themes/
將主題中的配置文件config.toml替換myblog目錄的config.toml文件。倘若想省心的話把 exampleSite 目錄下的全部文件複製到 myblog 目錄下
在這裏插入圖片描述

本地測試

hugo sever
在這裏插入圖片描述
瀏覽器輸入這個地址進行訪問

三、寫一篇博客

在這裏插入圖片描述
文章在content\blog目錄下
新建一個.md文檔進行編寫,需學習markdown的寫法

四、部署github

創建倉庫

在這裏插入圖片描述
倉庫命名按照<username>.github.io,不然會無法訪問(404警告)

生成public目錄

hugo --baseUrl="https://<username>.github.io"
打開public目錄,將public下的文件推送到遠程倉庫

git init
git add .
git commit -m "first commit"
git remote add origin <倉庫http> 
git push -u origin master

遠程訪問

https://<username>.github.io

五、可能遇到的問題

錯誤1

在這裏插入圖片描述
這時只需將配置文件 config.toml 這行 themesdir = “…/…/” 刪掉再hugo server即可

錯誤2

在這裏插入圖片描述
將這個 rich-content.md 文檔刪掉再hugo server即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章