# ByParam
> 返回给定页面集合按指定参数升序排序后的结果。
- 官方英文原文：https://gohugo.io/methods/pages/byparam/
- 本页规范地址：https://hugozh.cn/methods/pages/byparam/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：PAGES.ByParam PARAM
- 返回类型：page.Pages
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

---
如果前置元数据中没有给定的参数，Hugo 会改用项目配置中的同名参数（如果存在）。

```go-html-template
{{ range .Pages.ByParam "author" }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

要改为降序排列：

```go-html-template
{{ range (.Pages.ByParam "author").Reverse }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

如果目标参数是嵌套的，请用点号访问其字段：

```go-html-template
{{ range .Pages.ByParam "author.last_name" }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

