20240110-hexo-transplant


HEXO 博客移植

本文主要记载了在Ubuntu系统下移植Hexo搭建的个人网站到一台新电脑的步骤

前期准备——基本环境的搭建

首先是在Ubuntu下搭建基础环境,主要是git和node.js.在Ubuntu中比较简单,直接使用apt安装

安装Git

sudo apt install git-core

安装Node.js

在Ubuntu上安装Node.js也比较简单,直接使用apt安装即可。

sudo apt install npm
sudo apt install nodejs

安装HEXO

sudo npm install hexo-cli -g
sudo npm install hexo -g

准备移植

需要从原电脑复制的文件

  • _config.yml:站点配置
  • package.json:说明使用那些包
  • scaffolds:文章的模板
  • source:自己写的博客文件
  • themes:主题
  • .gitignore:限定在提交的时候哪些文件可以忽略

移植开始

在新电脑中新建myblog文件夹,并将复制的文件移动到该文件夹,并在该文件夹下执行:

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

然后就可以查看效果和部署了。

查看效果及部署。

运行 hexo g 生成博客。
运行 hexo s 查看博客。
打开 http://localhost:4000/,没问题的话,执行下一步。
执行 hexo d 推送到远程仓库部署。


Author: Jun Wang
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Jun Wang !