使用hexo搭建github.io博客(二)

使用hexo搭建github.io博客(一)这篇文章我是写在博客园上的,现在既然成功的搭建了github.io博客,那我就拿这篇开刀,真正的在我的github博客上发布一篇文章吧~

在搭建(一)完成后,就有了一个空的博客,里面只有一篇’Hello World’.现在就来学习如何写博客

在这之前,有很重要的一点需要补充,就是一定要打开github发来的邮件,然后点击验证,否则后面的操作都是无法实现的.

一.配置整站

打开hexo目录下的_config.yml文件,做如下配置,如果没有写到的,那就是保持默认:

# Hexo Configuration
## Docs: http://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: code_bunny's blog                      #设置header里的title
subtitle: never giveup reading!               #副标题
description: never giveup reading!            #描述
author: code_bunny                            #作者名,会显示在左下角
email: 973295131@qq.com                       #邮箱呗
language: zh-CN                               #设置中文
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

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

# Writing
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
  tab_replace:

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 5                               #设置每页显示多少篇文章
pagination_dir: page

# Extensions
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: yilia                              #设置要使用的模板,暂时不要改,以后会说到怎么换模板

# Deployment 这些还是按照上一篇配置
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: https://github.com/jinyanhuan/jinyanhuan.github.io
  branch: master

二.添加新文章

在hexo所在的文件夹下右键打开Git Bash

执行:hexo new “my new post”

注意,这里的”my new post”要有引号,必须是英文,不能是数字哦

然后在E:\hexo\source\_posts\下面找到这个名为my new post.md的文件,在编辑器里打开它.

如下配置:

title: "my new post"             #可以随意修改,可以是中文
date: 2015-03-10 17:54:06        #创建的时间,一般不改
categories: blog                 #文章文类
tags: [标签1,便签2]                 #文章tag标签,多个标签用逗号隔开
---
#这里开始使用markdown语法书写文章的内容

执行: hexo generate 生成

执行: hexo server 在本地预览

没有问题后,执行: hexo deploy 发布到github

现在为止,就已经搭建起博客,进行一些基本配置,并学会了怎么发表文章。下一篇讲解怎么更换博客主题,让博客变得美美哒


end

markdown 格式

这里是h1段落

这里是h2段落

这里是h3段落

一段文字里带有重点

一段文字里带有重点

一段文字里带有coding

表示引用文字内容


  • 这是无序列表项
  • 这是无序列表项
  • 这是无序列表项
  1. 这是有序列表项
  2. 这是有序列表项

下面这个是嵌套的列表

  • 外层列表项目
    • 内层列表项目
    • 内层无序列表项目
    • 内层列表项目
  • 外层列表项目

直接把一个URL现实为超链接: 我的博客园

这是一个图像: 兔子

行的开头空四格,表示程序代码(另外必须换行再换行,不能只换一次行):

Javascript:

/**
 * nth element in the fibonacci series.
 * @param n >= 0
 * @return the nth element, >= 0.
 */
function fib(n) {
    var a = 1, b = 1;
    var tmp;
    while (--n >= 0) {
        tmp = a;
        a += b;
       b = tmp;
    }
    return a;
}

document.write(fib(10));

end