利用最新版本的 hexo+next 重构了我的博客,下面简单记录了搭建博客的完整过程:node
建立新仓库
json
- 建立一个名称为 yourusername.github.io 的新仓库
- 这边的yourusername填写本身的用户名
- Github会识别并自动将该仓库设为 Github Pages
$ git config --global user.name "your name" $ git config --global user.name "your email"
$ ssh-keygen -t rsa -C "Github的注册邮箱地址"
- 在C:\Users\ASUS.ssh目录会有两个文件id_rsa和id_rsa.pub,打开id_rsa.pub
- 复制里面的全部内容到 SSH keys这里 的Key,Title随便填,即完成:Add SSH key
Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其余渲染引擎)解析文章,在几秒内,便可利用靓丽的主题生成静态网页segmentfault
$ npm install -g hexo-cli $ hexo init $ npm install
. ├── _config.yml ├── package.json ├── scaffolds ├── source | ├── _drafts | └── _posts └── themes
- _config.yml 文件中填上博客的基本信息,网站的详细配置点击这里 查看
- 注意,冒号后面都要有一个空格
deploy: type: git repo: https://github.com/username/username.github.io.git branch: master
$ npm install hexo-deployer-git --save
新建一篇博客文章windows
在hexo/source/_posts文件夹下新建md文件(不用加.md后缀)浏览器
$ hexo new 文件名
$ hexo g //生成网页文件 $ hexo s //localhost:4000本地预览效果 $ hexo d //部署
在浏览器输入https://username.github.io/ 就跳到博客网站缓存
$ git clone https://github.com/iissnan/hexo-theme-next themes/next
$ cd themes/next $ git pull
theme: next
//切换后,用命令清除下缓存 $ hexo clean //执行hexo s本地产看NexT主题效果 $ hexo s
切换next主题的风格
修改hexo/theme/next/_config.yml
# Schemes # scheme: Muse # scheme: Mist # scheme: Pisces # scheme: Gemini
默认只有首页和归档,若是还要添加,编辑hexo/themes/next/_config.yml
menu: home: / || home //首页 about: /about/ || user //关于 tags: /tags/ || tags //标签 categories: /categories/ || th //分类 archives: /archives/ || archive //归档 schedule: /schedule/ || calendar //日程表 sitemap: /sitemap.xml || sitemap //站点地图
$ hexo new page categories
- 成功后输出:INFO Created: ~/Documents/blog/source/categories/index.md
--- > title: 文章分类 > date: 2019-07-15 23:30:33 > type: "categories" ---
--- > title: GitHub+Hexo+Next搭建博客 > date: 2019-07-15 23:43:57 > categories: hexo ---
$ hexo new page tags
成功后输出:INFO Created: ~/Documents/blog/source/tags/index.md
--- > title: 文章分类 > date: 2019-07-15 23:54:22 > type: "tags" ---
--- > title: GitHub+Hexo+Next搭建博客 > date: 2019-07-15 23:43:57 > tags: hexo ---
根据以上步骤就能够搭建出一个属于本身的博客网站了,赶忙行动吧!
参考教程: