为什么使用Hexo
- 使用 Markdown 语法,语法简洁,展示效果尚可。
- Hexo主题丰富,界面简洁。
- 有全文检索插件,便于知识库的搜索。
- 静态页面,可直接托管在github pages和coding me pages服务器上
- 编译速度快,从Markdown编译生成静态页面的速度快
Hexo的依赖项
Hexo是基于Node.js的一个静态博客框架,所以编译环境必要有Node.js支持。
因此安装Hexo前必须先安装Node.js。
Windows平台下安装Node.js,很简单,直接到官网下载安装包安装即可。
安装Hexo
安装Node.js之后,会安装一个npm.cmd的可执行脚本。
可通过该脚本自动安装Hexo。
npm install hexo-cli -g
创建Hexo博客系统的开发目录
开发目录下包含有:
- Hexo编译环境
- Hexo所需要的主题、配置文件等各种资源
- Markdown格式的博客源文件,这些文件经Hexo编译后,会生成相应的HTML纯静态页面文件。
hexo init weaver2007.com
cd weaver2007.com
npm install
安装所需要的Hexo插件
npm install hexo-deployer-git --save
npm install hexo-generator-feed --save
npm install hexo-generator-searchdb --save
npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
安装Next主题
cd weaver2007.com
git clone https://github.com/iissnan/hexo-theme-next themes/next
配置站点配置文件
文件路径:weaver2007.com_config.yml
theme: next
language: zh-Hans
favicon: /self.png
search:
path: search.xml
field: post
format: html
limit: 10000
index_generator:
per_page: 10 ##首页默认10篇文章标题 如果值为0不分页
archive_generator:
per_page: 10 ##归档页面默认10篇文章标题
yearly: true ##生成年视图
monthly: true ##生成月视图
tag_generator:
per_page: 10 ##标签分类页面默认10篇文章
category_generator:
per_page: 10 ###分类页面默认10篇文章
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo:
github: https://github.com/weaver2007/weaver2007.github.io.git
coding: https://git.coding.net/weaver2007/weaver2007.coding.me.git
配置主题配置文件
scheme: Pisces
menu:
home: /
archives: /archives
about: /about
categories: /categories
tags: /tags
menu_icons:
enable: true
# Icon Mapping.
home: home
about: user
categories: th
tags: tags
archives: archive
commonweal: heartbeat
sidebar:
position: left
display: post
avatar: /self.png
highlight_theme: normal
# Social links
social:
微博: http://weibo.com/weaver2007
# Social Icons
social_icons:
enable: true
微博: weibo
# title
links_title: Links
links:
优快云: http://blog.csdn.net/weaver2007
reward_comment: 坚持原创技术分享,您的支持将鼓励我继续创作!
wechatpay: /path/to/wechat-reward-image
alipay: /path/to/alipay-reward-image
since: 2017年8月10日
# Local search
local_search:
enable: true
# MathJax Support
mathjax:
enable: true
cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
auto_excerpt:
enable: true
length: 150
scrollpercent: true
添加标签页面
hexo new page tags
编辑生成的source\tags\index.md文件。
title: 标签
date: 2014-12-22 12:39:04
type: "tags"
comments: false
添加分类页面
hexo new page categories
编辑生成的source\catetoried\index.md
title: 分类
date: 2014-12-22 12:39:04
type: "categories"
comments: false
---
添加about页面
hexo new page about_me
编辑生成的source\about_me\index.md
title: 关于
date: 2014-12-22 12:39:04
type: "about_me"
comments: false
---
新写一篇博客
hexo new test
编辑生成的source_post\test.md文件。
---
title: 测试页面
date: 2017-08-10 00:29:03
tags:
- 测试
- Hexo
- Next
- tags
categories: 基础设施
---
## 二级标题
编译Hexo博客
编译博客
cd weaver2007.com
hexo clean
hexo g
运行博客服务器
hexo s
浏览生成的博客
http://localhost:4000