HEXO使用小结

本文是我从自学前端开发以来,自己写的第一篇博客,为什么要写这一篇博客呢,原因有二,一是给自己没写过博客的hexo开个光,二是记录一下自己的每日所学所感。

关于hexo的基础配置

hexo的配置其实在网上已经有许多的大佬已经讲的一清二楚了,这里贴几个DALAO的链接,我在构建自己的博客的时候,就是以他们为参照的:

1. holaOla :Hexo安装和配置

2. Raspberry :Hexo 搭建博客-基础配置篇

以上基本可以在看完之后基本实现自己的bolg上线了,主要工作无非有四:
1.git的安装
2.GitHub的注册,本地SSHkey的设置
3.hexo的安装
4.node.js的环境搭建
实现了以上四项,自己的bolg基本上可以搭建成功。

关于hexo的设置和配置

以下为hexo在\Hexo\themes\next_config.yml下的配置文件(笔者使用的是next作为主题)

1
title:

副标题

1
subtitle:

网站描述

1
description:

作者昵称

1
author:

网站语言,默认英语,设置简体汉语

1
language: zh-Hans

时区,默认电脑时区

1
2
### timezone: 
timezone: Asia/Shanghai

网址设置

如果网站是放在子目录中,将url设置成’

1
http://yoursite.com/child'

将root设置成’/child/‘

1
If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'

###网址
url:

网站根目录。如果网站是放在子目录中,将root设置成’子目录名’

root: /

文章链接地址格式 。即文章存放的目录。

1
2
permalink: :year/:month/:day/:title/
permalink_defaults:

目录设置

资源文件夹,放在里面的文件会上传到github中

1
source_dir: source

公共文件夹,存放生成的静态文件

1
public_dir: public

标签文件夹,默认是tags。实际存放在source/tags中。

1
2
tag_dir: tags
rss_dir: rss

档案文件夹,默认是archives。

1
archive_dir: archives

分类文件夹,默认是categories。实际存放在source/categories中。

1
category_dir: categories

代码文件夹,默认是downloads/code

1
code_dir: downloads/code

国际化文件夹,默认跟language相同

1
i18n_dir: :lang

不需要渲染的文件夹或文件夹,放在[]中

这两个文件是百度和google的站长验证文件,不能渲染,否则会改变内容,不能验证过

1
skip_render: [baidu_verify_R9MZjdMkXT.html, google0f8fac7da2b48ef8.html, README.md, 模板.md]

写作选项

新建博文(帖子)的默认名称

1
2
#File name of new posts
new_post_name: :title.md

默认布局模板是post,而不是draft和page

1
default_layout: post

是否将标题转换成标题形式(首字母大写)

1
titlecase: false # Transform title into titlecase

在新标签页面中打开网页

1
2
external_link: true # Open external links in new tab
filename_case: 0

是否渲染草稿

1
render_drafts: false

启动 Asset 文件夹

1
post_asset_folder: false

把链接改为与根目录的相对位址

1
relative_link: false

显示未来的文章

1
future: true

代码块的设置

1
2
3
4
5
highlight:
enable: true #使用代码高亮
line_number: true #显示行号
auto_detect: true #自动检测语言
tab_replace:

分类和标签

默认分类

1
default_category: uncategorized

分类别名

1
category_map:

标签别名

1
tag_map:

日期和时间格式

Hexo 使用 Moment.js 来解析和显示时间。

1
2
3
4
#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

分页配置

—————下面选项需要对应插件的支持—————

1
2
3
4
5
#npm install hexo-generator-index --save
#npm install hexo-generator-archive --save
#npm install hexo-generator-category --save
#npm install hexo-generator-tag --save
#Set per_page to 0 to disable pagination

每页显示的文章量

1
#per_page: 20

首页的分页设置

1
2
index_generator:
per_page: 5

归档页的分页设置

1
2
3
4
archive_generator:
per_page: 30
yearly: true
monthly: true

标签页的分页设置

1
2
tag_generator:
per_page: 20

分页路径,在public中可以看到

1
#pagination_dir: page

Extensions 拓展插件配置

1
2
3
4
#Plugins: https://hexo.io/plugins/
plugins:
baidusitemap:
path: baidusitemap.xml

配置RSS

1
2
3
4
5
6
7
feed: 
#feed 类型 (atom/rss2)
type: atom
#rss 路径
path: atom.xml
### 在 rss 中最多生成的文章数(0显示所有)
limit: 0

自定义站点内容搜索

需要先安装插件:

1
2
3
#npm install hexo-generator-search --save
search:
path: search.xml

如只想索引文章,可设置为post

field: all

主题配置

1
2
3
4
#Themes: https://hexo.io/themes/
#theme: false #禁用主题
#theme: landscape
theme: next

部署配置

#Docs: https://hexo.io/docs/deployment.html
deploy:
type: git

#repo: https://github.com/changerhe.github.io.git
repo:

#部署到github
github: git@github.com:changerhe/changerhe.github.io.git,master
#部署到coding.net。取消注释,可同时部署
#coding: git@git.coding.net:chngerhe/blog.git,coding-pages

#type: baidu_url_submitter

文章目录
  1. 1. 关于hexo的基础配置
    1. 1.0.0.1. 1. holaOla :Hexo安装和配置
    2. 1.0.0.2. 2. Raspberry :Hexo 搭建博客-基础配置篇
  • 2. 关于hexo的设置和配置
    1. 2.0.1. 副标题
    2. 2.0.2. 网站描述
    3. 2.0.3. 作者昵称
    4. 2.0.4. 网站语言,默认英语,设置简体汉语
    5. 2.0.5. 时区,默认电脑时区
    6. 2.0.6. 网址设置
    7. 2.0.7. 如果网站是放在子目录中,将url设置成’
    8. 2.0.8. 网站根目录。如果网站是放在子目录中,将root设置成’子目录名’
    9. 2.0.9. 文章链接地址格式 。即文章存放的目录。
    10. 2.0.10. 目录设置
    11. 2.0.11. 资源文件夹,放在里面的文件会上传到github中
    12. 2.0.12. 公共文件夹,存放生成的静态文件
    13. 2.0.13. 标签文件夹,默认是tags。实际存放在source/tags中。
    14. 2.0.14. 档案文件夹,默认是archives。
    15. 2.0.15. 分类文件夹,默认是categories。实际存放在source/categories中。
    16. 2.0.16. 代码文件夹,默认是downloads/code
    17. 2.0.17. 国际化文件夹,默认跟language相同
    18. 2.0.18. 不需要渲染的文件夹或文件夹,放在[]中
    19. 2.0.19. 这两个文件是百度和google的站长验证文件,不能渲染,否则会改变内容,不能验证过
    20. 2.0.20. 写作选项
    21. 2.0.21. 新建博文(帖子)的默认名称
    22. 2.0.22. 默认布局模板是post,而不是draft和page
    23. 2.0.23. 是否将标题转换成标题形式(首字母大写)
    24. 2.0.24. 在新标签页面中打开网页
    25. 2.0.25. 是否渲染草稿
    26. 2.0.26. 启动 Asset 文件夹
    27. 2.0.27. 把链接改为与根目录的相对位址
    28. 2.0.28. 显示未来的文章
    29. 2.0.29. 代码块的设置
    30. 2.0.30. 分类和标签
    31. 2.0.31. 默认分类
    32. 2.0.32. 分类别名
    33. 2.0.33. 标签别名
    34. 2.0.34. 日期和时间格式
    35. 2.0.35. Hexo 使用 Moment.js 来解析和显示时间。
    36. 2.0.36. 分页配置
    37. 2.0.37. —————下面选项需要对应插件的支持—————
    38. 2.0.38. 每页显示的文章量
    39. 2.0.39. 首页的分页设置
    40. 2.0.40. 归档页的分页设置
    41. 2.0.41. 标签页的分页设置
    42. 2.0.42. 分页路径,在public中可以看到
    43. 2.0.43. Extensions 拓展插件配置
    44. 2.0.44. 配置RSS
    45. 2.0.45. 自定义站点内容搜索
    46. 2.0.46. 需要先安装插件:
    47. 2.0.47. 如只想索引文章,可设置为post
    48. 2.0.48. 主题配置
    49. 2.0.49. 部署配置
  • |