Hexo 博客搭建
部署
准备:linux环境
第一步,
apt install下载node,npm,git(若后续因为node、npm版本问题报错,则利用copilot提示下载新版本即可)第二步,连接Github
1
2git config --global user.name "GitHub 用户名"
git config --global user.email "GitHub 邮箱"Github账户上
Setting-SSH and GPG keys上放pub公钥文件,本地root/.ssh下要有私钥文件Git bash下输入ssh -T git@github.com, 输入yes
第三步创建Github Page仓库,到github上创建
用户名.github.io仓库本地安装Hexo博客程序
npm install -g hexo-cli这一步可能出错,是因为npm,node版本问题,用报错信息问问ai应该下载哪个版本的Hexo 初始化和本地预览
1
2hexo init # 初始化
npm install # 安装组件访问
http://localhost:4000部署Hexo到Github Pages
ynpm install hexo-deployer-git --save要求在空文件夹下按照,以后有关数据都在这个文件夹下操作
修改
.cofig,yml文件末尾的Deployment部分1
2
3
4deploy:
type: git
repository: git@github.com:用户名/用户名.github.io.git
branch: main- 运行
hexo d
成功啦, 网址输入github.io网址康康(有一定延时,更换浏览器绕开缓存影响)
- 运行
使用
创建文章
第一种使用方式:命令创建新的markdown,后编辑
1
hexo new "My New Post"
- 在source文件夹下出现
My New Post.md文件
- 在source文件夹下出现
第二种使用方式:修改已有的markdown文件
在开头添加如下信息
1
2
3
4
5
6
7
8
9
10
11
12
13---
title: Hello World # 标题
date: 2019/3/26 hh:mm:ss # 时间
categories: # 分类
- Diary
tags: # 标签
- PS3
- Games
---
摘要
<!--more-->
正文
发布文章
1 | hexo g |
网站设置
包括网站名称、描述、作者、链接样式等,全部在网站目录下的 _config.yml
更换主题
1 | git clone https://github.com/iissnan/hexo-theme-next themes/next |
后在config.yml文件中设置
常用命令
1 | hexo new "name" # 新建文章 |
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
