hexo搭建个人博客
闲来无事,体验一下hexo,在此记录
准备工具
安装
安装hexo
1 | // 全局安装hexo |
然后在浏览器输入localhost:4000即可
GitHub准备
新建仓库
新建一个仓库,名为Github-name.github.io,其中Github-name为GitHub账户名
然后在Settings中开启GitHub Pages,选择一个分支,save即可
验证:在Code中新建一个index.html,访问http://Github-name.github.io即可
设置个性域名(可跳过)
注册域名,写入仓库–>Settings–>GitHub Pages–>Custom domain中
可同时开启https,搞个免费的DV证书绑定到申请的域名即可
部署到GitHub
修改项目配置
在项目blog目录中找到_config.yml文件,找到deploy修改如下
1 | # Deployment |
部署
需要先安装一个推送工具
npm install hexo-deployer-git --save
next
1 | // 清缓存 |
访问http://Github-name.github.io,如果配置了custom domain,会指向自定义域名
至此基本流程OK
创建新博客
在项目目录下执行
hexo new post title
然后在source目录找到title.md即可编辑,此处了解下markdown
编辑完成后发布
1 | hexo clean && hexo g && hexo d // hexo g为generate,意为生成文件 |
done