利用hexo和GitHub搭建自己的博客

##安装准备软件
依次下载安装。

  1. Node.js
  2. Git

##验证软件正确安装

  • 同时按下Win键和R键(或者点击“开始菜单”->点击“运行”),打开运行窗口,输入“cmd”
    然后输入以下命令,结果与下图相同则说明安装正确,若不正确可以卸载软件重新安装
1
2
3
git --version
node -v
npm -v

img

申请GitHub

  • 点击->GitHub进入官网注册帐号
    -按下图分别输入用户名、邮箱、密码,然后点击注册

    zhuce

  • 按默认点击“Finish sign up”

    si

  • 点击”New repository”,新建一个版本库

    1

  • 输入Repository name:yourname.github.io(yourname与你的注册用户名一致,这个就是你博客的域名了)

    1

  • 到此github帐号申请完成

    1

  • 启用GitHub Page

    点击右边的“Setting”菜单进入设置,点击”Launch automatic page generator”

    2

    点击底部的”Continue to layouts”

    2

    最后点击”Publish page”,发布github默认生成的一个静态站点

    2

  • 验证邮箱

    点击个人设置

    2

    点击”Send verification Email”发送验证邮件

    2

    进入你的邮箱,查收验证邮件进行验证

    2

##安装Hexo

hexo是基于node.js的静态博客,官网也是搭建在GitHub上

  • 在电脑上新建一个blog文件夹,该文件夹用于存放你的博客文件,然后右键单击选择“Git Bash”

    3

    利用官网的命令安装

    1
    2
    3
    4
    5
    npm install hexo-cli -g
    hexo init blog
    cd blog
    npm install
    hexo server

执行完成后,打开浏览器,输入localhost:4000,就可以在本地看到你的个人博客了

##管理博客

  • 配置信息

    使用Notepad++编辑器(绿色软件无需安装,解压即可使用)打开blog/_config.yml文件,进行配置

    222

`

#博客名称
title: 我的博客
#副标题
subtitle: test
#简介
description: test
#博客作者
author: WJSDTA
#博客语言
language: zh-CN
#时区
timezone:

#博客地址,与申请的GitHub一致
url: http://xxx.github.io
root: /
#博客链接格式
permalink: :year/:month/:day/:title/
permalink_defaults:

source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: true
tab_replace:

default_category: uncategorized
category_map:
tag_map:

#日期格式
date_format: YYYY-MM-DD
time_format: HH:mm:ss

#分页,每页文章数量
per_page: 10
pagination_dir: page

#博客主题
theme: landscape

#发布设置
deploy: 
type: git
#xxx改为你的github用户名
repository: https://github.com/xxx/xxx.github.io.git
branch: master

`
  • 写一篇文章

    输入创建文章命令,生成一个md文件(/blog/source/_posts/)

    hexo new "这也是一个测试"

    用编辑器打开hello.md文件,编写完后保存

    `

    title: hello
    date: 2015-07-01 22:37:23
    categories:
        - 日志
        - 二级目录
    tags:
    
        - hello
    
    摘要:
        <!--more-->
    正文:
    

    `

##发布博客

yinyongle

Leo

  1. hhh
  2. jjj
  3. jroe
  4. gresg

print hello

1
2
import sys
print hello