Next主题的基本配置都差不多了,现在还有一个问题。
就是首页默认显示文章的全部内容,而不是预览,如何设置只显示部分呢?
一般有以下三种方法
1. 第一种方法
这种方式是 Hexo 提供的方式
在文章中使用 <!-- more -->
手动进行截断,显示效果如下:
明显可以看见,显示的内容不会被格式化。也可以根据 <!-- more -->
放置的位置,来控制要显示的预览内容。
2. 第二种方法
自动形成摘要,在主题配置文件
中查找如下这段代码:
# Automatically Excerpt. Not recommend.
# Please use <!-- more --> in the post to control excerpt accurately.
auto_excerpt:
enable: true
length: 150
如果没有则添加这段代码,可能不同的主题会不支持这种方法。、length
:设定文章预览的文本长度。默认截取的长度为 150
字符,可以根据需要自行设定。
这种方法的问题是:会格式化你文章的样式,直接把文字挤在一起显示,最后会有 …
。
而第一种方法,展示出来的就是你原本文章的样式。
3. 第三种方法
- 在文章的
front-matter
中添加description
字段,并填写要展示的预览信息
---
title: NexT主题基本属性的配置
date: 2020-05-08 12:15:32
tags: [Hexo_Blog,NexT,博客教程]
comments: true
categories: 博客教程
description: 如何配置样式、语言、菜单、侧栏等
---
- 在主题配置文件中将
excerpt_description
设置为true
# Automatically excerpt description in homepage as preamble text.
excerpt_description: true
这种方式的缺点在于,生成的预览信息在文章的详情页是不显示的。
- 这种方法,可以写文章的副标题。只要将
excerpt_description
设置为false
,如下:
# Automatically excerpt description in homepage as preamble text.
excerpt_description: false
综上,根据需要选择相应的方式。