github加hexo搭建个人博客(三)
安装 hexo 并生成网页
安装 hexo
创建一个任意名字的文件夹,这里我创建的是 My_Blog 。 进入该文件夹,右键进入 Git Bash 输入:
npm install -g hexo-cli |
输入:
hexo init |
初始化我们的博客。
输入:
hexo g |
生成静态文件。
输入:
hexo s |
进行本地查看。
在浏览器中输入: http://localhost:4000/
可以看到我们的博客已经布置成功了。
部署到github上
在 My_Blog 文件夹中,用笔记本打开 _config.yml 文件,在最后添加:
deploy: |
在 My_Blog 文件夹中,打开 Git Bash,输入:
npm install hexo-deployer-git --save |
安装 Git 部署插件。
第一次提交到 github ,会报错,我们需要先配置邮箱和用户名。
git config --global user.email "you@example.com" #注册 github 时的邮箱 |
依次输入:
hexo clean #清除缓存文件和静态文件 |
在浏览器中输入:
https://你的 github 用户名.github.io/ |
就可以看到相应的网站:
同时对应的 github 仓库也存在文件。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 哆啦酱的点心屋!
评论