Lamber's Blog

Hello World

字数统计: 388阅读时长: 1 min
2023/09/19

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

一、 快速开始

创建一篇新的文章

1
$ hexo new "My New Post"

More info: Writing

启动本地服务器

1
$ hexo server

More info: Server

生成静态文件

1
$ hexo generate

More info: Generating

部署到远程站点

1
$ hexo deploy

More info: Deployment

本地测试

1
$ hexo g && hexo s

部署发布文章

1
$ hexo clean && hexo g && hexo d

二、 迁移整个hexo

1. 准备Hexo所需要的前置环境

首先确保有如下环境

  • Node.js (Node.js 版本需不低于 10.13,建议使用 Node.js 12.0 及以上版本)
  • Git

2. 在新电脑上安装Hexo

安装Hexo

1
$ npm install -g hexo-cli

安装Hexo的相关模块

1
2
3
4
5
6
$ npm install
$ npm install hexo-deployer-git --save // 文章部署到 git 的模块
$ (下面为选择安装)
$ npm install hexo-generator-feed --save // 建立 RSS 订阅
$ npm install hexo-generator-sitemap --save // 建立站点地图

3. 备份源文件

首先将原来电脑上的博客下面的这些文件拷贝到新的电脑上面

1
2
3
4
5
6
_config.yml
package.json
scaffolds/
source/
themes/

4. 测试本地能否正常运行

1
$ hexo s

5. github添加 SSH Keys

首先在本地创建 SSH Keys:

1
$ ssh-keygen -t rsa -C "957742501@qq.com"

复制生成成功的 id_rsa.pub 里面的内容, 然后粘贴到github上面

用如下指令测试是否添加成功

1
$ ssh -T git@github.com

6. 部署发布文章

1
$ hexo clean && hexo g && hexo d
CATALOG
  1. 1. 一、 快速开始
    1. 1.1. 创建一篇新的文章
    2. 1.2. 启动本地服务器
    3. 1.3. 生成静态文件
    4. 1.4. 部署到远程站点
    5. 1.5. 本地测试
    6. 1.6. 部署发布文章
  2. 2. 二、 迁移整个hexo
    1. 2.1. 1. 准备Hexo所需要的前置环境
    2. 2.2. 2. 在新电脑上安装Hexo
    3. 2.3. 3. 备份源文件
    4. 2.4. 4. 测试本地能否正常运行
    5. 2.5. 5. github添加 SSH Keys
    6. 2.6. 6. 部署发布文章