• GitHub账号
  • mac/pc

环境

1
2
node.js
git

创建GitHub仓库

登陆GitHub,创建一个新的Respository

Repository name叫做{username}.github.io

{username}代表你的GitHub用户名,Repository name一点要叫这个

绑定域名

待定

绑定ssh秘钥

  • 设置git用户名和邮箱
1
2
git config --global user.name "liuxianan"
git config --global user.email "xxx@qq.com"// 填写你的github注册邮箱
  • 生成ssh秘钥
1
ssh-keygen -t rsa -C "邮件地址"

连续3次回车,不需要输入密码

公钥文件在在用户目录下.sshid_rsa.pub

  • 进入github -> settings -> SSH and GPG keys,点击new SSH key,将id_rsa.pub中的内容复制到其中,并确定,这样只要使用生成秘钥的电脑git访问GitHub是都不需要再输入用户名密码

安装Hexo

Hexo本体和部署插件

1
2
npm install -g hexo
npm install hexo-deployer-git --save

博客初始化

进入选的的文件夹

1
hexo init

此时会生成blog文件夹,这就是hexo默认的博客

1
2
3
cd blog
hexo g # 生成
hexo s # 启动服务

此时可以本地启动博客,去浏览器打开网址即可,默认是localhost:4000

可以看到一篇Hello World的文章

默认主题很简洁,想要更喜欢的主题可以去官网寻找https://hexo.io/themes/

主题选择

本次博主选择主题https://www.huweihuang.com/

GitHub地址https://github.com/huweihuang/hexo-theme-huweihuang

  • init
1
2
3
git clone https://github.com/huweihuang/hexo-theme-huweihuang.git ./hexo-huweihuang
cd hexo-huweihuang
npm install
  • 编辑配置文件

hexo-huweihuang/_config.yml

根据自己的喜好修改配置文件

以下配置仅针对该主题博客,其他的主题配置可能有所不同!

1
2
3
4
# Site
title: {标题}
subtitle: {副标题}
author: {作者名字}
1
2
3
# 下面的配置注释掉,是绑定域名的相关配置,以后也可以改成自己的域名
url: http://www.huweihuang.com/
root: /
1
2
3
# Site settings,在页面底部,酌情填写
SEOTitle: {作者名} | Blog
email: {邮箱}
1
2
# 填写你的GitHub用户名
github_username: {username}
大专栏  Hexo和github搭建个人博客 - 朱晨lass="highlight js">
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 以下为默认内容,可以先注释掉,也可以改成自己的相关网址
# 最外层的`friends:[]`不能注掉
friends: [
{
title: "CSDN Blog 胡伟煌",
href: "http://blog.csdn.net/huwh_"
},
{
title: "DockOne 胡伟煌",
href: "http://dockone.io/people/胡伟煌"
},
{
title: "阿里云栖社区 胡伟煌",
href: "https://yq.aliyun.com/u/huweihuang"
}
]
1
2
3
4
5
6
7
# github仓库的ssh地址,{username}代表你的github用户名
# {msg}代表你对每次部署的描述内容,相当于git commit -m 后面加的描述内容,可以不填
deploy:
type: git
repository: git@github.com:{username}/{username}.github.io.git
branch: master
message: {msg}
  • 本地预览
1
2
3
cd hexo-huweihuang
hexo g
hexo s

打开localhost:4000,可进行预览

评论功能

待定

编写markdown博客

新建markdown文件

开头如下,以下是本篇博客的例子

tags是标签,可自行添加

top填1表示置顶,0表示不置顶

标题和时间可自行修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---
title: "Hexo和github搭建个人博客"
catalog: true
toc_nav_num: true
date: 2019-07-06 10:51:24
subtitle: "你的博客你做主"
header-img: "/img/article_header/article_header.png"
tags:
- Hexo
- Github
catagories:
- Hexo
updateDate: 2019-07-06 22:26:24
top: 0
---

接下来就可以编写正文了…

markdown文件要放在hexo-huweihuang/source/_posts文件夹中

部署博客

1
2
3
cd hexo-huweihuang
hexo g
hexo d # deploy部署

也可使用hexo g -d或者hexod -g

如果有些奇怪的问题可以hexo clean清除已经生成的部署文件,再重新执行

结束

访问{username}.github.io即可访问你的私人博客

如果绑定域名也可通过域名访问


Hexo和github搭建个人博客 - 朱晨的更多相关文章

  1. Hexo结合Github搭建个人博客

    如何搭建 我采用了ICARUS主题,根据以下教程完成了部署 https://www.cnblogs.com/liuxianan/p/build-blog-website-by-hexo-github. ...

  2. 记自己利用hexo和github搭建个人博客的过程

    --------------------------------------可能我书写的方式跟别人顺序不一样,但这是我的成功经验------------------------------------ ...

  3. 《Hexo+github搭建个人博客》

    <Hexo+github搭建个人博客> 文/冯皓林 完稿:2016.4.22-2016.4.23 注意:本节教程只针对Windows用户.本教程由无人赞助,赞助写出. <Hexo+g ...

  4. 使用Node.js+Hexo+Github搭建个人博客(续)

    一.写在前面 在我的上一篇博客<使用Nodejs+Hexo+Github搭建个人博客>中,已经介绍了如何使用 Hexo 在 Github Pages 上搭建一个简单的个人博客.该篇博文将在 ...

  5. Mac上基于hexo+GitHub搭建个人博客(一)

    原文地址: http://fanjiajia.cn/2018/11/23/Mac%E4%B8%8A%E5%9F%BA%E4%BA%8Ehexo+GitHub%E6%90%AD%E5%BB%BA%E4% ...

  6. 如何用hexo+github搭建个人博客

    搭建环境 1.安装 Node.js: https://nodejs.org/en/ windows下点击链接,下载安装即可;Linux下更加简单,在终端下输入sudo apt-get install ...

  7. Ubuntu+Hexo+Github搭建个人博客

    Ubuntu+Hexo+Github搭建个人博客 目录 目录 目录 1. 简介 环境 2. Git安装及配置 2.1 安装Git 2.2 创建Git仓库 2.3 配置git仓库 2.4 添加公钥 3. ...

  8. jekyll+github搭建个人博客总结

    jekyll+github搭建个人博客 经过一天多的折腾,终于算是搭建好了自己的个人博客,看到有些社区评论说:在windows下用jekyll搭建静态博客,简直就自讨苦吃,但是都到一半了,有什么办法呢 ...

  9. 使用 Hexo 在 GitHub 上建立博客 · Utopia's Daily Note

    使用 Hexo 在 GitHub 上建立博客 # 写在前面 其实我在一月份的就开始写了三篇博客文章,你没有看错,只是写了三篇,然后,就没有然后了.我还在其中一篇文章中写着,不知道自己能够坚持多久.事实 ...

随机推荐

  1. 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第七天】(redis缓存)

    https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...

  2. PAT甲级——1152.Google Recruitment (20分)

    1152 Google Recruitment (20分) In July 2004, Google posted on a giant billboard along Highway 101 in ...

  3. TPO3-2Depletion of Ogallala Aquifer

    The vast grasslands of the High Plains in the central United States were settled by farmers and ranc ...

  4. 关于TensorFlow2的tf.function()和AutoGraph的一些问题解决

    在使用TensorFlow的AutoGraph的时候出现了一些问题,特此记录 AutoGraph did not convert this function. Try decorating it di ...

  5. $.proxy和$.extend

    $.proxy用法详解 参考:https://www.cnblogs.com/alice626/p/6004864.html jQuery中的$.proxy官方描述为: 描述:接受一个函数,然后返回一 ...

  6. java 之断言

    今天用idea的智能提示冒出一个assert关键字,愣是没看懂!!!还是太菜了.上网查了一下,这个关键字是断言. 什么是断言? 我也说不清楚,反正就是对jvm的操作.java的错误分为两种,一种叫er ...

  7. day44-线程

    #1.开启线程: from threading import Thread import os def func(): print('func',os.getpid()) t = Thread(tar ...

  8. Java接口和抽象类区别

    1.抽象类 [public] abstract class ClassName { abstract void fun(); } extends 包含抽象方法的类称为抽象类,但并不意味着抽象类中只能有 ...

  9. Python实现求1-1000以内的素数

    def func(): for i in range(2,1000): # count表示被整除的次数 count = 0 for j in range(1,i+1): if i%j==0: coun ...

  10. jQuery实现button按钮提交表单

    在JSP页面中,通常使用button按钮提交表单数据,使用jQuery实现代码如下: <span style="font-family:Comic Sans MS;font-size: ...