关于hexo与github使用过程中的问题与笔记

快速阅读

如何用github 和hexo 创建一个blog

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

  • - 必须是io后缀。一个帐户 只能建立一个

2. 绑定域名 , A记录指向ip, cname记录指向homehe.github.io

3. 配置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

友情提示

​ 我对我的文章负责,发现好多网上的文章 没有实践,都发出来的,让人走很多弯路,如果你在我的文章中遇到无法实现,或者无法走通的问题。可以直接在公众号《爱码农爱生活 》留言。必定会再次复查原因。让每一篇 文章的流程都能顺利实现。

posted @ 2019-07-27 00:00  水木  阅读(380)  评论(0编辑  收藏  举报