4.配置_config.yml

4.1 _config.yml常用结构说明

直接上我的配置吧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Site 网站
# 网站标题
title: linjiad_个人博客
#网站副标题
subtitle: 柳外轻雷池上雨,雨声滴碎荷声
#网站描述
description: 这个人很懒什么也没写
keywords:
#您的名字
author: linjiad
#网站使用的语言
language: JS
#网站时区。
timezone:

# URL 网址
#网址
url: http://linjiad.github.io
#网站根目录
root: /
#文章的 永久链接 格式 :year/:month/:day/:title/
permalink: :year/:month/:day/:title/
#永久链接中各部分的默认值
permalink_defaults:

# Directory 目录
# 资源文件夹,这个文件夹用来存放内容。
source_dir: source
# 公共文件夹,这个文件夹用于存放生成的站点文件。
public_dir: public
# 标签文件夹
tag_dir: tags
# 归档文件夹
archive_dir: archives
# 分类文件夹
category_dir: categories
# Include code 文件夹
code_dir: downloads/code
# 国际化(i18n)文件夹
i18n_dir: :lang
# 跳过指定文件的渲染,您可使用 glob 表达式来匹配路径
skip_render:

# Writing 文章
# 新文章的文件名称
new_post_name: :title.md # File name of new posts
#预设布局,以后就在source下的_post下查看文章
default_layout: post
#把标题转换为 title case
titlecase: false # Transform title into titlecase
#在新标签中打开链接
external_link: true # Open external links in new tab
#把文件名称转换为 (1) 小写或 (2) 大写
filename_case: 0
#显示草稿
render_drafts: false
#启动 Asset 文件夹
post_asset_folder: true
#把链接改为与根目录的相对位址
relative_link: false
#显示未来的文章
future: true
#代码块的设置
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:

# Home page setting分页
index_generator:
path: ''
per_page: 10
order_by: -date

# 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
#每页显示的文章量 (0 = 关闭分页功能)
per_page: 10
#分页目录
pagination_dir: page

# Extensions 扩展
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
#当前主题名称。值为false时禁用主题
theme: miho

# Deployment
## Docs: https://hexo.io/docs/deployment.html
#部署部分的设置
deploy:
type: git
repo: https://账号:密码@github.com/你的名字/你的名字.github.io.git
branch: master

5.主题themes

5.1下载themes

主题可以在这里找都是免费的哦!
看好的主题可以再github中搜索名字,比如我的主题是,miho可以直接搜索
如图所示
点击进入后可以下载成.zip文件,之后再把文件解压到themes下
如图所示

5.2配置themes

之后再设置_config.yml中theme

theme: miho

6.图片处理

6.1下载图片处理包

下载图片处理包

npm install hexo-asset-image –save

6.2配置_config.yml

把主页配置文件_config.yml 里的post_asset_folder:这个选项设置为true

post_asset_folder: true

6.3创建markdown文档

再运行hexo new” xxxx” 生成md文件时source/_posts文件夹内除了xxxx.md文件还有一个同名的文件夹

6.4放置和调用图片

在xxxx.md中想引入图片时,先把图片复制到xxxx这个文件夹中,然后只需要在xxxx.md中按照markdown的格式引入图片:

1
![你想输入的替代文字](xxxx/图片名.jpg)

7.MIHO主题

7.1MIHO配置说明

在该主题下会有一个_congig.yml文件,该文件是主题的配置文件
如图所示
_congig.yml配置就不一一说明可以参看README.md或者看这里

7.2MIHO列表图片踩坑

这里面还有个大坑,就是列表图片总找不到,原因是路径不对
坑在这里如图所示
改成这个样子

1
2
3
4
5
6
<% if (post.cover_picture) { %>
<img src="<%- (/^(http:|https:)?\/\//.test(post.cover_picture) ? post.cover_picture :config.url.replace(/\/$/, '') + '/' + post.cover_picture )%>" alt="<%- post.title %>" title="<%- post.title %>">
<% } else { %>
<img src="<%- (/^(http:|https:)?\/\//.test(theme.cover_picture) ? theme.cover_picture
: config.url.replace(/\/$/, '') + '/' + theme.cover_picture ) %>" alt="<%- post.title %>" title="<%- post.title %>">
<% } %>

之后在引用图片的时候需要加日期

1
2
3
4
5
6
7
8
---
title:
date: 2018-05-11 09:48:26
tags:
categories:
author:
cover_picture: 2018/05/11/hexo2/menu.png
---

图片日期需要和date保持一致

8.尾声

常用命令

1
2
3
4
5
6
7
8
9
10
hexo clean清除缓存文件 (db.json) 和已生成的静态文件 (public)。
hexo generate 生成静态文件。
hexo deploy 部署网站
hexo server 启动服务器。默认情况下,访问网址为: http://localhost:4000/
-p, --port 重设端口
-s, --static 只使用静态文件
-l, --log 启动日记记录,使用覆盖记录格式
hexo new page "about" 创建新的连接目录

hexo new '文章名' 创建新的文件

更多需求可查询hexo官网
更多miho主题可查询miho
该项目地址放在这儿啦

最后更新: 2018年11月10日 16:58

原始链接: http://linjiad.github.io/2018/05/11/hexo2/

× 请我吃糖~
打赏二维码