hexo博客迁移

hexo博客迁移

背景

最开始使用wordpress写博客,方便是方便,但感觉不够干净、不够优雅,所以后来开始写markdown格式的博客,使用hexo部署在github上,但是平时使用的电脑有很多台,GitHub上公开的又只有public文件夹的静态页面,没有把markwodn文件一并提交,因此也不能通过github来同步,所以就想干脆把hexo项目放在云服务器上,要写新文章就写好markdown上传到云服务器去提交,也省的在各个电脑上配置。本文简要介绍把hexo项目迁移到云服务器上的步骤。

复制文件夹上传到云服务器

除了node_modules,其他文件全部上传

安装nodejs、Hexo和其他依赖

1
2
3
4
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g hexo-cli
sudo npm install

建立git连接

1
2
3
git config --global user.name "xinhaojin"
git config --global user.email "xinhaojin@qq.com"
ssh-keygen -t rsa -b 4096 -C "xinhaojin@qq.com"

把公钥/root/.ssh/id_rsa.pub中的内容添加到github-setting-ssh key

1
2
git init
git remote add origin https://github.com:xinhaojin/xinhaojin.github.io.git

更新博客

上传markdown到blog/source/_posts文件夹
然后就可以发布新文章了

1
2
3
hexo clean
hexo g
hexo d

markdown模板

1
2
3
4
5
6
7
8
9
10
11
---
title: 文章标题
tags: []
categories:
- - 软件安装配置
date: 2023-05-20 13:30:00
---
## xxx
### xxx
![](url)
<url>

hexo博客迁移
https://xinhaojin.github.io/2023/07/04/hexo博客迁移/
作者
xinhaojin
发布于
2023年7月4日
许可协议