Windows 10安装Hexo个人博客 并更换主题模板

一、提前安装nodejs和git

具体方法略过

https://nodejs.org/
https://registry.npmmirror.com/binary.html?path=git-for-windows/v2.46.0.windows.1/

二、安装Hexo

1、打开Git Bash

切换到你想创建博客的目录,如 d:/note,然后右键打开Git Bash

2、配置国内加速rpm源并安装Hexo

npm config set registry http://registry.npmmirror.com
npm install -g hexo-cli

3、初始化Hexo

hexo init 
npm install
npm install hexo-deployer-git --save

4、测试博客

hexo g      #生成页面
hexo s      #本地预览

5、预览页面

 http://localhost:4000/

三、安装主题模板

1、进入 Hexo项目的根目录,然后运行以下命令安装Aurora 主题

npm install hexo-theme-aurora hexo-plugin-aurora --save
npm cache clean --force   #如有异常先清理缓存

2、将这个模版到复制或下载后,命名为 _config.aurora.yml ,放到项目根目录

一共有两个配置文件,一个是 Hexo自身的配置,一个是主题专用的配置
. # Hexo 项目根目录.
├─ _config.yml # Hexo 配置文件
└─ _config.aurora.yml # 主题配置

四、主题模板配置

Hexo配置文件 _config.yml

1、设置 url 和 permalink

url 为自己的博客地址,permalink 参数为 /post/:title.html
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://example.com
permalink: /post/:title.html
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

2、设置代码高亮

关闭 Highlight,设置 enable 为 false。使用 prismjs,设置 enable 为 true,将 preprocess 设置为 false
highlight:
  enable: false
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: true
  preprocess: true
  line_number: true
  tab_replace: ''

3、设置主题

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: aurora

4、主题配置文件 _config.aurora.yml

site:
  subtitle: 嬴政's Blog
  author: 大秦嬴政
   # 博客名字,会在 header 的 logo 下方显示
  nick: 
  description:
  link: '/'
  language: en
  multi_language: true
   # 开启博客的多语言支持
  logo: https://www.baidu.com/img/flexible/logo/pc/result@2.png
  avatar:
  # 备案信息
  beian:
    number: '海ICP20240000'
    link: ''
  police_beian:
    number: ''
    link: ''

5、生成预览

hexo clean & hexo g & hexo server    #运行本地环境
TIP 改变了任何配置都需要重新生成 Hexo的静态文件!
如使用Mark-magic插件,可以将本地Joplin中的笔记,发布到Hexo,具体见另一篇笔记。
参考:
https://www.cnblogs.com/fan223/articles/16996213.html
https://aurora.tridiamond.tech/cn/guide/getting-started.html