搭建博客
搭建博客
一.电脑系统环境配置
·安装下载git
·安装下载Node.js
安装完毕可以执行输出版本号进行验证是否成功安装:
1 | . npm -v |
二.安装HEXO
·全局安装Hexo命令行工具
执行:
1 | . npm install hexo-cli -g |
安装完毕验证是否成功安装:
1 | . hexo -v #输出版本号 |
·初始化Hexo博客项目
决定好存放blog文件的目录,在该目录打开git输入执行:
1 | . hexo init blog #创建Hexo初始模板 |
三.GitHub Pages设置
·注册账号
访问http://www.github.com/注册GitHub账号(username和邮箱非常重要!!!)
·创建账号仓库
仓库名为 username.github.io,配置可见性为公开
·Git全局身份配置
先查看本地:
1 | . ls -al ~/.ssh #查看是否存在密钥 |
是否存在ssh key,若存在直接全部删除。然后输入:
1 | . git config --global user.name "<username>" |
(这里的username和email优先与GitHub账号一致哦)
·生成shh密钥
输入:
1 | . ssh-keygen -t rsa -C "<your email>" |
(此处的邮箱为注册GitHub账号时使用的),后续一路按回车键即可
·获取ssh密钥
输入执行:
1 | . cat ~/.ssh/id_rsa.pub #输出密钥 |
后复制密钥(整个输出),在GitHub打开设置找到SSH and GPG keys进行编辑
完成后执行:
1 | . ssh git@github.com #查看密钥配对情况 |
四.部署到GitHub
·配置_config.yml
编辑blog文件中的_config.yml,修改Deployment部分:
1 | . deploy: |
·安装Git部署插件
输入执行:
1 | . npm install hexo-deployer-git --save |
·博客部署
输入执行:
1 | . hexo deploy |
ok,如果顺利的话到这一步你就成功了!!!
注意!!!一定保存好自己的blog文件,要不然只能像我一样重搭
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick Start
Create a new post
1 | $ hexo new "My New Post" |
More info: Writing
Run server
1 | $ hexo server |
More info: Server
Generate static files
1 | $ hexo generate |
More info: Generating
Deploy to remote sites
1 | $ hexo deploy |
More info: Deployment