1.github中要新建一个与用户名同一样的仓库, 如:homehe.github.io

  • 必须是io后缀。一个帐户 只能建立一个
  1. 绑定域名 , A记录指向ip, cname记录指向homehe.github.io
  2. 配置sshkey
  • 个人设置 -> SSH and GPG keys -> New SSH key
  • 测试 是否成功 ssh -T git@github.com =》You've successfully authenticated 表示成功
    3.2 配置用户名和邮件

$ git config --global user.name "liuxianan"// 你的github用户名,非昵称 $ git config --global user.email "xxx@qq.com"// 填写你的github注册邮箱

4.安装hexo

npm install -g hexo
在要目录下进行初始化 hexo init=>会花费时间 长一点。

$ hexo g # 生成
$ hexo s # 启动服务

hexo就会在public文件夹生成相关html文件,这些文件将来都是要提交到github去的:

hexo s是开启本地预览服务,打开浏览器访问 http://localhost:4000 即可看到内容
如果端口被占用:

这里我们以8081端口为例讲解。

按下Win+R调出命令行窗口,输入netstat -aon|findstr "8081",找到指定行最后一列的数字(PID),我们这里是9548. 输入tasklist|findstr "9548",发现是javaw.exe占用了8081端口。 再次输入taskkill /f /t /im javaw.exe结束该进程。

修改主题

//下载主题到themes/yilia 目录
$ git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
修改_config.yml中的theme: landscape改为theme: yilia,然后重新执行hexo g来重新生成
关于yilia目录的生成

在根目录下运行
$ npm i hexo-generator-json-content --save
在根目录下的_config.yml 中增加

jsonContent:

        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true

部署之前要安装有关部署的

$ npm install hexo-deployer-git -save
关于部署的配置 ,注意:号后面一定要有空格 。

deploy:
type: git
repository: git@github.com:homehe/homehe.github.io.git
branch: master


本文由 hcb 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论