Next 主题为搜索引擎优化(SEO)提供了有用的选项。

默认情况下,当你在 Hexo 配置文件中设置了你的网址 url: http://example.com
 后,Hexo 会创建一个规范链接标签(canonical link tag)。更多详细信息可以在“合并重复 URL”部分找到。

在 Next 主题配置文件中将 index_with_subtitle
 的值设置为 true
,可以将副标题信息添加到首页。

Next 主题配置文件示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
index_with_subtitle: true
```

你可以在 Hexo 配置文件中设置副标题(subtitle)。
## 外部链接(ExtURL)
### 描述

搜索引擎会优先扫描 `<a>`标签。尽管你可以添加 `external` 、`nofollow`、`noopener`、`noreferrer`等类似的属性,但无论如何,你网站上的所有外部链接都会被索引。然而,这里有一个技巧:爬虫不会执行 JavaScript,而客户端会在本地设备上执行。

这个标签提供了一种方法,可以在不使用 `<a>` 标签的情况下设置任何外部链接。因此,像 Yandex 这样的爬虫不会从你的网站上泄露链接权重,这对 SEO 非常有用。这个标签的功能包括:
- 将 HTML 中的 `<a>` 标签替换为 `<span>`  标签。

- 使用 BASE64 对 URL 进行加密和解密。用户在浏览器源代码中看不到 BASE64 格式的链接,但他们可以看到一个工具提示,显示链接指向的地址,或者显示在 title  标签参数中指定的自定义标题。

- 使用此标签的反向链接不会被任何监控扫描。这就像你通过 JavaScript 在新标签页中打开一个新链接一样。

- 它也适用于移动设备。

这个标签是专门为更好的 SEO 优化而创建的。任何试图通过网络钓鱼链接欺骗最终用户的行为都是不被允许的!
### 设置

在主题配置文件的“SEO 设置”部分中,只需要启用一个设置:

Next 主题配置文件示例:
阅读全文 »

下面将详细介绍如何结合 Python 的requests 、pytest 和Allure 来实现接口自动化测试,主要分为以下几个步骤:

1. 环境准备

首先需要安装所需的库,可以使用pip 进行安装:

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
pip install requests pytest allure-pytest
```
### 2. 编写测试用例

创建一个 Python 文件,例如test_api.py ,在其中编写接口测试用例。以下是一个简单的示例,假设我们要测试一个获取用户信息的接口:
```python
import requests
# 定义接口测试类
class TestAPI:    
# 测试获取用户信息接口的方法    
def test_get_user_info(self):        
# 定义接口的 URL
url = 'https://jsonplaceholder.typicode.com/users/1'        
# 发送 GET 请求       
response = requests.get(url)        
# 断言响应状态码是否为 200        
assert response.status_code ==200        
# 断言响应数据是否包含 'name' 字段        
assert 'name' in response.json()
```
### 3. 运行测试用例

使用pytest 运行测试用例,并生成 Allure 测试报告所需的数据:
```bash
pytest test_api.py --alluredir=./allure-results

上述命令中,–alluredir 指定了 Allure 测试报告数据的保存目录。

阅读全文 »

预连接

NexT 支持添加预连接资源提示,以便尽早与字体和插件的来源建立连接。

您可以通过在 NexT 配置文件中设置 preconnect: true  来启用它。

NexT 配置文件

1
2
3
4
5
6
7
8
preconnect: true
```
### 文本对齐

NexT 允许自定义文章/页面中的文本对齐方式。text-align  CSS 属性设置块元素或表格单元格框的水平对齐方式。
<table><thead><tr><th style="font-weight: 700;color: rgb(0, 0, 0);border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf=""></span></section></th><th style="font-weight: 700;color: rgb(0, 0, 0);border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">效果</span></section></th></tr></thead><tbody><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">start</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">如果方向是从左到右,则等同于 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">left</span></code><span leaf="">;如果方向是从右到左,则等同于 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">right</span></code><span leaf=""></span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">end</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">如果方向是从左到右,则等同于 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">right</span></code><span leaf="">;如果方向是从右到左,则等同于 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">left</span></code><span leaf=""></span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">left</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">行内内容对齐到行框的左边缘。</span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">right</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">行内内容对齐到行框的右边缘。</span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">center</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">行内内容在行框内居中。</span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">justify</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">行内内容被对齐。文本应该被间距调整,使其左边缘和右边缘与行框的左边缘和右边缘对齐,但最后一行除外。</span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">justify-all</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">与 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">justify</span></code><span leaf=""> 相同,但也会强制最后一行对齐。</span></section></td></tr><tr><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">match-parent</span></code></td><td style="border: 1px solid rgb(214, 214, 214);padding: 6px 13px;"><section><span leaf="">类似于 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">inherit</span></code><span leaf="">,但 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">start</span></code><span leaf=""> 和 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">end</span></code><span leaf=""> 的值会根据父元素的方向计算,并被替换为相应的 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">left</span></code><span leaf=""> 或 </span><code style="font-family: Menlo, Monaco, Consolas, &#34;Courier New&#34;, monospace;font-size: 0.85em;color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);border-radius: 3px;padding: 0.2em 0px;"><span leaf="">right</span></code><span leaf=""> 值。</span></section></td></tr></tbody></table>

**NexT 配置文件**
阅读全文 »

Next 允许用户在菜单中添加自定义页面。

  • 添加新页面 →

  • 设置前置事项值 →

  • 编辑菜单

在终端中切换到站点根目录。使用 hexo new page custom-name  命令创建一个名为 custom-name  的新页面:

1
2
3
4
5
6
cd hexo-site
hexo new page custom-name
```

前置事项(Front-matter)是文件开头的一块 YAML 或 JSON 格式的内容,用于配置文章的设置。更多关于前置事项的设置可以在 
Front-matter 文档  中找到。如果你愿意,也可以在 custom-name/index.md  中添加内容。

title: custom-name
date: 2014-12-22 12:39:04

阅读全文 »

文章摘要设置

在首页显示文章的一部分并提供一个链接以查看完整文章是一种常见的需求。NexT 提供了两种方式来控制文章在首页的显示方式。换句话说,你可以使用以下方法来显示文章摘要和一个“阅读全文”按钮。

  • 使用 <!-- more --> 标签

  • 使用 excerpt_description

在你的文章中手动插入 <!-- more -->  来分隔文章,这是 Hexo 推荐的方式。

如果你在文章的前置元数据(front-matter)中添加了 description  并将其值设置为文章摘要,NexT 默认会将 description  作为首页的前置文本。如果没有 description ,那么文章的全部内容将成为首页的前置文本。

阅读全文 »

网站版权设置

网站启动时间

默认情况下,NexT会在页脚显示当前年份,例如“© 2020”。您可以通过在NexT配置文件的footer 部分中编辑since 的值,将其配置为显示时间范围,例如“© 2015 - 2020”。

NexT配置文件示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
footer:
  since: 2020
```

默认情况下,NexT会在页脚的年份和版权信息之间显示一个红色的“心形”图标,并带有动画效果。您可以通过在NexT配置文件的footer 部分中编辑icon 的值来配置它。
- name :图标名称。

- animated :是否启用动画效果。

- color :图标颜色。

页脚图标的名称可以在Font Awesome网站上找到,推荐使用heart
图标。

NexT配置文件示例:
阅读全文 »

默认情况下,侧边栏仅在有目录的帖子中显示,并且位于左侧。您可以通过编辑 NexT 配置文件中的 sidebar
 设置来更改它。

侧边栏有几种选项,包括 position
(位置)、width_expanded
(展开宽度)、width_dual_column
(双栏宽度)、display
(显示)、padding
(内边距)和 offset
(偏移)。

配置头像

默认情况下,NexT 不会在侧边栏中显示头像。您可以通过编辑 NexT 配置文件中的 avatar
 设置来配置它。

  • url
    :头像的链接地址。

  • rounded
    :是否将头像设置为圆形。

  • rotated
    :鼠标悬停时头像是否旋转。

阅读全文 »

NexT 的核心理念之一是隐藏复杂的细节,为您提供一个简单但灵活的配置,以便您能够轻松使用。

文档中给出的值通常是允许的典型值,而不是默认值。它们可能与 NexT 配置文件中的值不同。

NexT 快速入门

缓存支持

NexT v6+ 支持缓存内容生成。您可以在 NexT 配置文件的 cache  部分将 enable  的值设置为 true ,如下所示:

阅读全文 »

1. 简介

jq 是一个轻量级、高性能的 JSON 数据处理工具,支持过滤、转换、查询等操作。其语法简洁灵活,广泛用于命令行或脚本中处理 API 返回数据、日志解析等场景。

2. 安装

3. 基本语法

阅读全文 »

Hexo 安装

如果你是第一次使用 Hexo,请确保你的环境设置正确。开始之前,你需要:

  1. 安装 Node.js
    :你可以从 Node.js 官方网站下载安装程序,使用操作系统的包管理工具,或者使用 Node.js 版本管理工具(如 nvm)。安装完成后,你应该能够在命令行中执行 node
     和 npm
     命令。

  2. 全局安装 Hexo CLI
    :运行 npm i -g hexo-cli
    。安装完成后,你应该能够在命令行中执行 hexo
     命令。

  3. 初始化 Hexo 站点
    :执行 hexo init hexo-site
    。你可以将 hexo-site
     替换为其他路径名称,但本文将以 hexo-site
     为例。这个目录将在下文中被称为站点根目录。

在安装过程中,请确保你有可靠的网络连接。如果遇到问题,可以考虑为 npm 或 git 配置代理,或者使用镜像站点。

更详细的安装步骤,请参考 Hexo 文档,了解如何安装 Hexo 和初始化站点。安装成功后,你应该能够在命令行中执行 hexo
(或 npx hexo
),并且在你的站点根目录中必须有 package.json
、source
、themes
 等目录:

阅读全文 »
0%