Hexo

概述

https://hexo.io

主题

Fluid

https://github.com/fluid-dev/hexo-theme-fluid
https://hexo.fluid-dev.com/

Next

https://github.com/iissnan/hexo-theme-next
https://notes.iissnan.com/

配置环境

方法一:在宿主机中配置nodejs环境

1
2
mkdir hexo && cd hexo
hexo init . && npm install hexo-cli -g

方法二:基于node构建hexo镜像

  1. 创建 Dockerfile

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    FROM node:latest
    WORKDIR /var/www/hexo
    RUN echo "Asia/Shanghai" > /etc/timezone \
    && rm /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    RUN apt-get update && apt-get -y install cron git \
    && git config --global init.defaultBranch main \
    && git config --global user.name "xxx" \
    && git config --global user.email "xxx@example.com"
    RUN npm install npm hexo-cli -g
    CMD ["/bin/bash", "-c", "hexo clean && hexo generate && hexo server"]
  2. 创建镜像

    1
    docker build -t hexo .
  3. 启动镜像

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    docker stop hexo
    docker rm hexo
    docker run \
    --detach \
    --tty \
    --interactive \
    --name hexo \
    --hostname=hexo \
    --publish 80:4000 \
    --restart unless-stopped \
    --volume /home/hexo:/var/www/hexo \
    hexo
  4. 进入镜像docker exec -it hexo bash

  5. 更新模块npm update

  6. 部署站点hexo generate --deploy或者hexo deploy --generate

常用命令:

1
2
3
4
5
6
hexo init .   # 初始化
npm install # 安装包
npm update # 更新包
hexo clean # 清理缓存
hexo generate # 更新页面
hexo server # 启动服务

参考文献


Hexo
https://laplac2.github.io/blog/hexo/
作者
Laplace
发布于
2022年1月2日
许可协议