搭建属于自己的博客,通过github提供的github page的免费域名,以及hexo框架来快速搭建。目前遇到的问题,以提供解决方案。
前提条件
拥有github账号、node以及git。
创建库
库名设为gitname.github.io,其中gitname是你的github账号昵称,如下图这里gitname为前面的luckbb。
设置guthub page的分支地址
hexo安装配置
可参照Hexo https://hexo.io/官网,目前使用的是hexo3.2,node版本为v8。
下载hexo
1 | npm install -g hexo-cli |
检测hexo
1 | hexo -v |
初始化
选择一个文件夹,初始化,不填参数在本路径下创建。
1 | hexo init [folder] |
_config.yml配置
主要的几个参数
1 | # Site |
repo的地址是创建github的代码仓库地址,建议设置ssh配置。
1 | # Deployment |
More info: configuration
新建文件
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
遇到问题
Deployer not found: git
1 | npm install hexo-deployer-git --save |
More info: deployment
初始化时npm包下载失败
网络原因,可直接在初始化文件夹 npm install或者淘宝镜像
next主题标签分类
在开启标签/分类时,可能出现路径问题,其主要步骤为
- 在hexo站点目录。通过指令
hexo new page tags/categories
,会在source文件下创建tags/categories文件夹,其目录下均有index.md文件 - 在index.md文件中设置type类型,标签为tags,分类为categories,举例标签如下:
1 | --- |
- 修改主题配置文件_config.yml,给菜单添加链接
1 | menu: |
More info:next