橦言无忌

一个不想改变世界的程序媛

hexo的主要搭建过程

前言

这个基本就是简单的搭建示例,对前端小白很友好,也够简单整洁,是喜欢的风格没跑了~

安心码文了~

1,安装hexo

1
2
3
4
5
6
# 使用 npm 一键安装 Hexo 博客程序
npm install -g hexo-cli
hexo init # 初始化
npm install # 安装组件
hexo g # 生成页面
hexo s # 启动预览

访问 http://localhost:4000,出现 Hexo 默认页面,本地博客安装成功!

2,连接github

1
2
3
git config --global user.name "xinwen"
git config --global user.email "hxinwen1218@sina.com"
ssh-keygen -t rsa -C "hxinwen1218@sina.com" # 之后一路回车,大概率会在/root/.ssh中生成公钥和私钥

登录github,进入Settings->SSH and GPG keys->New SSH key,title随意起,将刚才的公钥(id_rsa.pub)复制进去即可。

3,新建github Pages仓库

新建仓库,注意Repository name,请务必为:用户名.github.io

博客地址:https://用户名.github.io

4,部署hexo到Github Pages

1
2
3
4
5
6
7
8
# 安装 hexo-deployer-git
npm install hexo-deployer-git --save

# 然后,修改 _config.yml 文件
deploy:
type: git
repository: git@github.com:用户名/用户名.github.io.git
branch: main

然后,运行hexo d即可部署到Github Pages.

5,hexo其他信息

5.1 hexo常用命令

1
2
3
4
5
6
7
hexo new "postName" #新建文章
hexo new page "pageName" #新建页面
hexo generate #生成静态页面至public目录
hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo deploy #部署到GitHub
hexo help # 查看帮助
hexo version #查看Hexo的版本

5.2 hexo命令缩写

1
2
3
4
hexo n == hexo new
hexo g == hexo generate
hexo s == hexo server
hexo d == hexo deploy

5.3 hexo组合命令

1
2
hexo s -g #生成并本地预览
hexo d -g #生成并上传

6,hexo博客文件夹

1
2
3
4
5
6
7
8
9
.
_config.yml #网站的配置信息
package.json #应用程序的信息
scaffolds #模板文件夹
source #存放用户资源,markdown文档
_drafts
_posts
themes #主题文件夹
public #网站文件

7 参考文章

// 代码折叠