美文网首页我爱编程程序员前端生活点滴
使用Hexo & Github,搭建属于自己的博客

使用Hexo & Github,搭建属于自己的博客

作者: ld1024 | 来源:发表于2018-06-25 10:08 被阅读31次

本篇目录:

  • 关于Hexo
    • Hexo特性
  • 博客搭建思路
  • 搭建过程
    • ① 安装Node.js
    • ② 安装Git
    • ③ Github仓库准备
    • ④ Hexo创建
    • ⑤ Hexo和Github关联
    • ⑥ Hexo源码备份
    • ⑦ 后期维护以及博客更新

经过在网上各种找资料,踩过各种坑,终于搭建好了hexo,直接与gitbub一起使用,搭建起自己的免费的博客

关于Hexo

Hexo是一款基于Node.js的静态博客框架。

Hexo

Hexo特性

  • 风一般的速度
    Hexo基于Node.js,支持多进程,几百篇文章也可以秒生成。
  • 流畅的撰写
    支持GitHub Flavored Markdown和所有Octopress的插件。
  • 扩展性
    Hexo支持EJS、Swig和Stylus。通过插件支持Haml、Jade和Less.

博客搭建思路

Hexo搭建博客

搭建过程

① 安装Node.js

② 安装Git

③ Github仓库准备

1.  创建仓库,http://your-user-name.github.io
2.  创建两个分支:master 与 hexo
    touch README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/your-user-name/your-user-name.github.io.git
    git push -u origin master

    在本地新建一个分支: 
        git branch hexo
    切换到你的新分支: 
        git checkout hexo
    将新分支发布在github上: 
        git push origin hexo
    至此分支创建完毕
3.  在github网站设置hexo为默认分支

④ Hexo创建

在本地your-user-name.github.io文件夹下通过Git bash依次执行
1.  npm install hexo
2.  hexo init <folder>
如果指定 <folder>,便会在目前的资料夹建立一个名为 <folder> 的新资料夹;否则会在目前资料夹初始化。
3.  npm install
4.  npm install hexo-deployer-git
5.  hexo generate  生成网站
6.  hexo server  启动本地服务器
网站会执行在http://localhost:port (port 预设为 4000,可在 _config.yml 设定)

⑤ Hexo和Github关联

1.  修改_config.yml中的deploy参数,分支应为master;
2.  hexo generate -deploy(可以简化为hexo g -d) 生成推送到github的master分支
此时访问your-user-name.github.io即可查看生成的站点内容

⑥ Hexo源码备份

1.  进入本地的your-user-name.github.io文件夹下
2.  git clone https://github.com/your-user-name/your-user-name.github.io.git
此时显示分支为hexo
3.  git add --all
4.  git commit -m "blog source commit"
5.  git push origin hexo
至此博客源代码就备份到了hexo分支上面。

⑦ 后期维护以及博客更新

在本地对博客进行修改(添加新博文、修改样式等等)后,通过下面的流程进行管理。

  1. 依次执行git add .、git commit -m "..."、git push origin hexo指令将改动推送到GitHub(此时当前分支应为hexo);
  2. 然后再执行hexo g -d发布网站到master分支上。

相关文章

  • Hexo主题底部默认信息修改

    首先不知道怎么使用Hexo搭建免费博客的可以先看我的上一篇文章使用HEXO+Github,搭建属于自己的免费博客 ...

  • 使用Hexo & Github,搭建属于自己的博客

    经过在网上各种找资料,踩过各种坑,终于搭建好了hexo,直接与gitbub一起使用,搭建起自己的免费的博客。 关于...

  • 用hexo创建github博客

    倒腾了好久才用hexo加github搭建好属于自己的博客,好激动,为此写篇博客记录一下。要使用hexo的话,需在你...

  • HEXO 趟坑笔记

    我的blog 如何使用Hexo在github上搭建静态博客 如何使用Hexo在github上搭建静态博客 感冒两天...

  • 使用 Github Page + Hexo 搭建自己的博客

    使用 Github Page + Hexo 搭建自己的博客 前言 Github Page 是 Github 提供的...

  • hexo 搭建

    hexo 搭建自己的私人博客hexo 搭建自己的私人博客登录github地址 创建并登录自己的github账号 创...

  • 使用hexo 搭建github博客

    使用hexo 搭建github博客 目的: 通过hexo 在github上 搭建一个个人技术博客的网站 我之前已...

  • Hexo安装教程

    使用Hexo+Github一步步搭建属于自己的博客 https://www.cnblogs.com/fengxio...

  • Github pages Hexo博客访问量统计

    之前使用Hexo搭建了自己的github.io博客https://littlefogcat.github.io/。...

  • Hexo+Github搭建个人博客

    Hexo+Github搭建个人博客 目录 [TOC] 1. 简介 首次通过Hexo和Github搭建自己的博客,尝...

网友评论

    本文标题:使用Hexo & Github,搭建属于自己的博客

    本文链接:https://www.haomeiwen.com/subject/vbbeyftx.html