搭建hexo博客系统
前几天完成了一个hexo主题,便想着出一篇关于搭建hexo博客系统的博客。在正文开始以前,假设你已掌握以下技能:css
npm install hexo-cli -g // 在你准备存放项目的路径下 hexo init blog
下载 hexo-theme-sky 主题git
cd blog git clone https://github.com/iJinxin/hexo-theme-sky theme/sky
修改博客根目录下的配置文件 _config.yml ,启用 sky 主题github
theme: sky
安装依赖项npm
npm install
npm install hexo-renderer-scss --save
运行hexo
hexo server
启动服务后,访问 http://localhost:4000 预览主题app
到目前为止,本地博客系统就已经启动完成了。
更多配置
设置站点使用语言
主题默认使用中文,能够在 _config_yml 中修改 languages 字段进行修改ssh
languages: en
目前支持的语言:布局
若是你有兴趣添加其余语言在主题中能够给我发PR。post
设置建站时间, 做者
底部默认的建站时间为今年
© 2018 by John Doe
修改 _config 中 author 字段,而后添加 since 字段
author: iJinxin
since: 2017
修改后的效果为
© 2017 - 2018 by iJinxin
添加标签页
新建标签页
hexo new page tags
编辑生成的 tags/index.md 文件,设置 tags 布局
layout: tags
在主题配置文件 themes/_config.yml 文件中
# menu menu: Home: / Archives: /archives Tags: /tags
添加分类页
新建分类页
hexo new page categories
编辑生成的 categories/index.md 文件,设置 categories 布局
layout: categories
添加About页面
新建about页
hexo new page about
编辑生成的 about/index.md 文件,设置 about 布局
layout: about
在主题配置文件 themes/_config.yml 文件中
# menu menu: Home: / Archives: /archives Tags: /tags About: /about
设置底部社交信息
目前仅引入了github, 微博,知乎
在配置文件 _config.yml 添加社交帐号名
github_username: your github username
weibo_username:
zhihu_username:
添加评论服务
主题使用了 gitment,在使用以前,须要获取client ID,和client seret。
点击这里 注册一个新的 OAuth Application。其余内容能够随意填写,但须要保证填入正确的callback URL (通常是评论页面对应的域名,如 https://imsun.net,https://iJinxin.github.io/ 等)
而后在配置文件 _config.yml 中添加评论
comment:
owner: your github ID
repo: 存储评论的repo
id: your client ID
secret: your client seret
更多关于 gitment 的介绍,能够查看 做者博客
示例
在 source/_post 目录下新建 hello.md 文件, 内容以下
--- title: hello, date: 2018-10-29 10:10:10 tags: thinking categories: 随笔 --- 这里是文章的开头部分,在设置了“阅读全文”功能后,首页只显示该部分的文字 <!-- more --> 这里是文章的剩下部分,点击“文章标题”或者“阅读全文”后才能看见。
使用github page搭建线上版本
网上有不少教程,具体能够参考 这一篇
须要注意的是,若在本机上没有设置SSH的话,在发布时会报错,如何在本机上设置SSH能够参考 设置SSH。
## 最后