hexo + github 博客搭建

使用hexo搭建博客,托管于github


原文链接

配置环境: node + git

hexo

安装hexo

npm install hexo -g

初始化hexo

hexo init 或 hexo init <文件名>

注:不加文件名会在当前目录下下载初始文件

生成静态页面

hexo generate 或 hexo g

本地启动服务

hexo server 或 hexo s

浏览器输入http://localhost:4000可以看到主页,默认主题landscape


github

新建项目

项目名称与git账号名称一致

复制项目ssh地址


配置hexo+git

在本地hexo初始化后的文件找到 _config.yml
在文件中找到

deploy:

修改为

deploy:
type: git
repo: [email protected]:yourname/yourname.github.io.git //复制的ssh地址,yourname为账户名
branch: master

部署

部署前要先安装自动部署工具

npm install hexo-deployer-git --save

部署

hexo d

浏览器输入 yourname.github.io可以看到博客的主页了(yourname为git账户名)


hexo 命令

hexo init //初始化项目
hexo generate //生成静态页面
hexo clean //清除生成静态页面
hexo server //启动本地服务
hexo deploy //部署
hexo new page 'example' //新建名为example页面
hexo new 'example' //新建名为example文章

报错处理

ERROR Deployer not found: git

解决方法:
npm install hexo-deployer-git –save

接下来就可以开启博客之旅啦!^_^

发布了36 篇原创文章 · 获赞 4 · 访问量 1万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章