从hexo转向hugo
本篇记录一下blog从hexo转向使用hugo的过程
- 安装依赖
-
Git
-
Go: refer to https://go.dev/doc/install
-
Dart Sass:
通过snap安装(推荐): 安装并启动snap:
sudo apt-get install snapd sudo apt-get install snapcraft
如果中途网络卡住,清除并重新安装:
sudo killall apt apt-get sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock* sudo dpkg --configure -a
使用snap安装dart sass:
sudo snap install dart-sass
如果snap命令执行失败(cannot communicate with server: Post http://localhost/v2/snaps),则手动启动snapd
#root@wsl: dart-sass 1.69.0 from Joe Mooring (jmooring) installed
通过homebrew安装: Install homebrew ** 下载并安装到默认目录 /home/linuxbrew/.linuxbrew/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Add to your linux PATH:
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)" test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bashrc
Install Dart Sass using homebrew:
brew install sass/sass/sass
- 安装hugo:
- 使用ubuntu apt安装hugo(推荐):
sudo apt install hugo
- 使用snap安装hugo:
sudo snap install hugo
- 使用homebrew安装hugo:
brew install hugo
- hugo demo:
- 启动hugo的http server:
hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo "theme = 'ananke'" >> hugo.toml
hugo server
- 自定义
- 部署到cloudflare page https://gohugo.io/hosting-and-deployment/hosting-on-cloudflare-pages/
- 静态图片目录
直接新建目录存放在
/static/
下,编译时会自动打包至/public/
下(与/public/posts
同级) markdown中引用静态图片
![img1](/pic/20230128/1.jpg)
- 主题目录
- 添加主题
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
- 修改主题
hugo配置文件
hugo.toml
:
baseURL = 'https://timemeet.me/'
languageCode = 'zh-cn'
title = 'timemeet.me'
theme = 'ananke'
cloudflare pages配置文件 config.toml
:
baseurl = "/"
languageCode = "zh-cn"
theme = "ananke"
paginate = 5
...