本地部署hexo

hexo博客搭建

安装前提

  • node.js
  • git

设置淘宝镜像源

npm install -g cnpm --registry=https://registry.npm.taobao.org

安装Hexo

1)打开git创建blog文件夹

mkdir blog

2)安装hexo框架

cnpm install -g hexo-cli

3)初始化hexo

hexo init  //初始化

4)打开hexo

hexo s  //启动服务,默认端口4000
hexo s -p xxxx  //自定义端口

localhost:4000

5)博客文件在blog_post,写完后更新

hexo clean
hexo g
hexo s

6)安装hexo-deployer

cnpm install --save hexo-deployer-git  //安装git插件

7)部署到github

  1. 新建一个仓库复制仓库地址
  2. 打开hexo根目录的_config.yml
  3. 设置deploy信息,
deploy:
  type: git
  repository: your github
  branch: master

8)部署

hexo d

更换主题

  1. 将主题文件clone到hexo文件中的themes中

    git clong https://xxxx  themes/xxxx
    
    
  2. 设置根目录下的_config.yml

    theme: xxxx
    
    
  3. 重启

hexo clean
hexo g
hexo s

原文地址:https://www.cnblogs.com/ed1s0n/p/13033158.html