友情链接
效果
配置教程
创建友链页面
在你的 Hexo 项目根目录下执行如下命令即可自动创建一个友链页面。
$ hexo new page links
注意:
友链样式默认根据 title: links
来匹配。
如果需要自定义页面的标题,需要在 Front Matter 里面添加 type: links
,即可自定义页面标题。
示例1:
source/links/index.md
---
title: Links
date: 2020-05-13 14:16:07
---
示例2:
source/links/index.md
---
title: 自定义标题
date: 2020-05-13 14:16:07
type: links
---
修改配置文件
在 Redefine 主题配置文件 _config.redefine.yml
的 navbar
配置项里面启用 links
。
_config.redefine.yml
navbar:
links:
Friends: #取名随意
icon: fa-solid fa-link #图标
path: /links/
(放在二级菜单也可以)
创建友链存放文件
在你的 Hexo 项目的 source
文件夹里增加 _data
文件夹。
如果已经有了 _data
文件夹,则忽略这一步。
在 _data
文件夹里新建 links.yml
文件。
在 links.yml
文件里按如下格式增加你的友链。
source/_data/links.yml
- name: EvanNotFound's Blog
link: https://ohevan.com
description: 用香港记者的速度更新文章
avatar: https://evan.beee.top/avatar.png
- name: Example Site
link: https://example.com
description: Example Site Description
avatar: https://www.youtube.com/watch?v=dQw4w9WgXcQ
- ......
注意:
如果你创建完,发现这个页面 Front Matter 是这个格式:
source/links/index.md
---
title:
'[object Object]': null
date:
'[object Object]': null
---
那么请打开 hexo 根目录下的 scoffalds/page.md
把:
scaffolds/page.md
---
title: { { title } }
date: { { date } }
---
改为:
scaffolds/page.md
---
title: {{ title }}
date: {{ date }}
---
然后再删除刚刚创建的 links 页面,重新执行命令
$ hexo new page links
即可。
更改友链列数
在 Redefine 主题配置文件 _config.redefine.yml
的 page_templates
配置项里面修改 friends_column
。
配置项名称:page_templates.friends_column
_config.redefine.yml
page_templates:
friends_column: 3
类型 | 可选值 | 默认值 |
---|---|---|
数字 | 2 | 3 | 3 |