hexo-butterfly-gitee个人博客搭建
安装前提: node.js git环境
安装hexo:
npm install -g hexo-cli
初始化hexo 项目:
hexo init
例如 hexo init myBlog
命令执行完成之后,会在myBlog文件夹下生成以下项目目录:
myBlog
├── _config.landscape.yml
├── _config.yml
├── db.json
├── package-lock.json
├── package.json
├── public
├── scaffolds
├── source
└── themes
hexo clean 清除缓存
hexo g 生成静态文件在public文件夹下
hexo s 运行
hexo s 运行,访问:http://localhost:4000,即可看到hexo生成的静态页面。
更换主题:butterfly
butterfly主页的展示页面:jerryc.me
主题安装:
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
在myBlog文件夹中新建文件_config.butterfly.yml, 并将_config.yml中的文件复制到config.butterfly.yml中,以后直接在config.butterfly.yml中配置主题相关参数即可。
在config.yml中配置:
theme: butterfly
languages: zh-CN
以此执行:hexo clean, hexo g, hexo s 命令,第一次操作可能会报错:
Errror:Cannot find module 'cheerio'
Require stack:
执行以下命令即可:
npm install cheerio@0.22.0 --save
刷新网址,可以看到页面会报以下错误:
extends includes/layout.pug block content .........
对应安装以下插件即可:
npm install hexo-renderer-pug hexo-renderer-stylus
再次执行, 成功!
tips🐎butterfly主题相关设置介绍:
config.butterfly.yml文件中设置主题
- 菜单设置,关键字搜索 menu,放开注释即可。
- 标签,分类菜单,新建hexo new page “your page”
例如 myBlog\source\categories\index.md
---
title: 文章分类
date: 2023-04-07 15:03:11
type: 'categories'
---
tips:分类(type: 'categories'),标签:(type: 'tags')
-
全局搜索功能
引入Local search 本地搜索
安装hexo-generator-search
npm install hexo-generator-search --save
在config.yml文件中配置:
# Search 全局搜索
search:
path: ./public/search.xml
field: post
format: html
limit: 100
_config.butterfly.yml中启用全局搜索:
local_search:
enable: true
- 部署到gitee
1.生成公钥
ssh-keygen -t rsa
C盘/用户/用户名/.ssh目录下找到id_rsa.pub文件,将内容复制到码云->个人设置—>安全设置->SSH公钥
2.ssh -T git@gitee.com
控制台输入以上命令,检验是否配置成功。
配置_config.yml中的repo信息:
deploy:
type: git
repo: #你的仓库地址,如:https://gitee.com/stoneking1/blog.git
branch: master
直接通过hexo来发布到gitee,需要安装以下插件:
npm install hexo-deployer-git --save
安装成功之后,执行 hexo d ,即可看到提交的内容。
页面如下:个人博客地址