Hexo博客本地配置

0. 环境

  • nodejs
  • git

1. 本地安装

  1. 选择一个本地文件夹路劲(不带中文)
  2. 右键 open git bash here
  3. 输入:
bash 复制代码
npm install -g hexo-cli

安装hexo

  1. 输入 hexo -v,查看是否安装成功:

2. 初始化

  1. 继续输入:
bash 复制代码
hexo init

然后我报错了

换个方法:

  1. https://github.com/hexojs/hexo-starter 下载代码
  2. 直接解压,所有文件丢到我的那个文件夹内
  3. 启动git bash,执行:
bash 复制代码
npm install
  1. 验证是否成功:
bash 复制代码
hexo s
  1. 打开 localhost:4000,查看效果

3. 设置主题

我采用的是butterfly

https://github.com/jerryc127/hexo-theme-butterfly

  1. 下载:
bash 复制代码
git clone https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
  1. 安装主题依赖
bash 复制代码
npm install hexo-renderer-pug hexo-renderer-stylus --save
  1. 启用
    _config.yml 文件中:
yml 复制代码
theme: butterfly
  1. 启动
powershell 复制代码
hexo clean
hexo s
hexo clean ; hexo s(两行可以合并)

也可以直接配置powershell:

bash 复制代码
notepad $PROFILE 

然后在打开的记事本里添加:

bash 复制代码
# Hexo快捷键 Hexos :清理 + 启动本地预览
function hexos {
    hexo clean ; hexo s
}

# Hexo快捷键 Hexod :清理 + 生成 + 部署上线
function hexod {
    hexo clean ; hexo g ; hexo d
}

回到终端:

bash 复制代码
. $PROFILE

4. 主题优化

这个部分我还没搞定

首先要去安装plug和stylus:

bash 复制代码
npm install hexo-renderer-pug hexo-renderer-stylus --save

在根目录里新建 _config.butterfly.yml,然后把这个东西丢进去:

yml 复制代码
# ==================== 1. 站点基础信息 ====================
avatar: /img/avatar.jpg  # 头像:把图片放到 source/img/ 下
favicon: /img/favicon.ico # 浏览器标签图标

# ==================== 2. 顶部导航菜单(专栏/标签/归档/关于) ====================
menu:
  首页: / || fa fa-home
  专栏: /categories/ || fa fa-th-large
  标签: /tags/ || fa fa-tags 
  归档: /archives/ || fa fa-archive
  关于: /about/ || fa fa-user

# 菜单图标库,保持默认即可
menu_icons:
  enable: true

# ==================== 3. 页面布局 & 侧边栏 ====================
sidebar:
  position: left         # 侧边栏位置 left/right
  display: always        # always 一直显示 | hide 移动端隐藏
  offset: true

# 侧边栏组件(按需开启)
sidebar_widget:
  author: true           # 作者信息卡片
  category: true         # 专栏分类
  tag: true              # 标签云
  archive: true          # 文章归档
  webinfo: true          # 网站统计

# ==================== 4. 文章样式(重点:适配你的技术文章) ====================
# 文章摘要
post_excerpt:
  enable: true
  length: 150            # 首页摘要字数

# 文章内目录(右侧悬浮目录,长文章必备)
toc:
  enable: true
  number: false          # 目录是否带序号
  expand: true           # 默认展开全部目录

# 代码块(技术博客核心)
highlight:
  theme:
    light: github        # 浅色模式代码主题
    dark: github-dark    # 暗黑模式代码主题
  copy: true             # 代码块显示「复制按钮」
  fold: false            # 代码块默认不折叠

# 文章顶部元信息(日期、标签、阅读量等)
post_meta:
  page:
    date_type: created
    date_format: YYYY-MM-DD
    word_count: true     # 显示文章字数
    min2read: true       # 显示阅读时长
    categories: true
    tags: true

# 图片懒加载(提升加载速度,图片多必开)
lazyload:
  enable: true

# ==================== 5. 全站搜索功能(站内检索文章) ====================
local_search:
  enable: true
  preload: false
  CDN:

# ==================== 6. 页脚 ====================
footer:
  owner: 你的昵称
  start_year: 2026       # 建站年份
  runtime: true          # 显示网站运行时长
  icp: ''                # 国内备案号,没有就留空

# ==================== 7. 基础动画 & 特效 ====================
enter_transition: true   # 页面进场动画
back2top:
  enable: true           # 回到顶部按钮
  side: right

# ==================== 8. 评论(后续可选配置,先关闭不影响使用) ====================
comments:
  use: false             # 暂时关闭评论,后面需要再开启

个人about界面:

  1. 输入:
bash 复制代码
hexo new page about
  1. 打开 source/about/index.md,写入内容
相关推荐
Setsuna_F_Seiei7 小时前
前端的 AI 学习之路 01 之 Agent API 调用 - 和 Agent 的基础对话
前端·人工智能·ai编程
threerocks7 小时前
AI 原生软件开发生命周期手册 - 如何借助 AI,逐阶段改造软件开发生命周期
前端·javascript·后端
徐小夕7 小时前
3分钟从想法到Agent上线:我们开源了一款AI可视化工作流“IDE”
前端·算法·github
why技术9 小时前
eli5,我觉得这个全网在吹的技能,使用体验真的很一般啊。
前端·人工智能·后端
excel9 小时前
记录升级 nuxt3 到 nuxt4 记录
前端
剑胆琴心静水深流10 小时前
全栈之路6---web集成与呈现
前端·vue.js·spring boot·分布式·spring·前端框架·npm
前端snow10 小时前
ai agent -- Memory汇总
前端
ITresearchGuest11 小时前
AI 焦虑下,前端该何去何从
前端·人工智能
Codiggerworld11 小时前
Chrome DevTools 隐藏神技:这 5 个调试技巧你可能从来没用过
前端·chrome·chrome devtools
旋生万物11 小时前
【终极实战】用Python从零“生成“一个宇宙:螺旋干涉模型的代码实现
开发语言·前端·人工智能·react.js·php·wpf