在Coding上搭建Hexo个人博客

先注册一个Coding账号,然后创建一个项目这个项目的名字应该是{username}.coding.me

安装hexo脚手架

$ npm install -g hexo-cli

建站

安装完 Hexo 后,就可以正式开始建站了。

在终端中输入以下内容:

$ mkdir Hexo
$ hexo init Hexo
$ cd Hexo
$ npm install

其中,Hexo 是文件夹的名字,可以修改。

修改_config.yml文件

在本地浏览自己的博客没问题后,我们就需要把它部署到 Coding 上了,先在根目录下找到_config.yml文件,并进入编辑。我们找到deploy这一项,修改看下面:

# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  #我们是使用 git 来部署的。
  type: git
  # git 仓库的地址。
  repo: https://git.coding.net/johnh/myblog.git
  # 分支名称。
  branch: master

按照上面的修改好_config.yml文件过后,我们还需要安装hexo-deployer-git才能够部署到 Coding 上面。

npm install hexo-deployer-git --save

接着我们就生成静态页面和把代码push到 Coding 上:

$ hexo g
...

$ hexo d
...

注意把代码push到 Coding 上之前会让你输入你的 Coding 用户名和密码。

更换皮肤

1.我选择了hexo-theme-yilia这个主题,简洁大方,功能齐全;

这是他的地址:https://github.com/litten/hexo-theme-yilia

.具体添加方法:

安装
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
 
配置
修改hexo根目录下的 _config.yml : theme: yilia
$ hexo g
...

$ hexo d
...

 错误(缺少模块)

 
 

缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save

3、在根目录_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

猜你喜欢

转载自www.cnblogs.com/ZaraNet/p/10281562.html