搭建hexo静态博客

使用hexo搭建博客,并将博客部署到github

需要的工具

正式开始

  1. 在任意目录下新建一个文件夹,如blog,在该文件夹下右键打开git bash here,执行npm install -g hexo-cli,安装hexo
  2. 执行hexo init
  3. 执行npm install
  4. 根据提示依次执行npm audit fixnpm audit fix --force
  5. 执行hexo g,生成博客
  6. 执行hexo s后,可以在 http://localhost:4000 上预览博客
  7. 在github上新建一个仓库,命名为username.github.io,其中username必须为你github的用户名
  8. 执行npm install hexo-deployer-git --save,安装deployer-git,用来将hexo推送到github
  9. 修改配置文件:在文件夹中找到并打开_config.yml文件,将文件末尾的deploy部分更改如下,repo: 后填写你新建的github仓库的地址。注意: 请使用英文冒号以及冒号后要有空格
deploy:
  type: git
  repo: https://github.com/Tuzilow/Tuzilow.github.io.git
  branch: master
  1. 分别执行hexo cleanhexo ghexo d,即可在 https://username.github.io (username为你的用户名)中看到自己的博客

添加新的文章

  1. 执行hexo new "文章标题",会在\source\_posts下生成一个md文件,在该文件中编辑文章即可
  2. 写完文章后,分别执行hexo cleanhexo ghexo d,即可将文章发布成功,如果网站上没有出现文章可以稍等一会儿再刷新。
posted @ 2019-08-31 09:51  Tuzilow  阅读(170)  评论(0编辑  收藏  举报
TOP