# 主页的自定义标签查询？

**URL:** https://meta.discourse.org/t/custom-tag-query-for-homepage/106658
**Category:** Support
**Created:** [2019年一月16日 04:25 UTC](https://meta.discourse.org/t/custom-tag-query-for-homepage/106658 "2019-01-16T04:25:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rkaplan](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@rkaplan](https://meta.discourse.org/u/rkaplan)
#### Post date: [2019年一月16日 04:25 UTC](https://meta.discourse.org/t/custom-tag-query-for-homepage/106658/1 "2019-01-16T04:25:42Z")

</div>

我正在阅读这篇博客文章

> **[It’s Time We Talked About Tags](https://blog.discourse.org/2017/10/its-time-we-talked-about-tags/)**
>
> Consider the typical sections of a daily newspaper: Arts, Sports, Business, Travel, Local, and World. Any given article belongs to just one of those sections, and the content in each section is quite different, such that some people, for example, may...

我注意到在自定义主页上提到了“标签查询”：

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/b/5bd81b172d40e9bb87ece45cbf794732048cbe37.jpeg)

我知道可以在搜索栏中使用 tags:XXX 的格式按标签搜索。我也知道可以通过生成的 URL 重新创建该搜索。但我不明白的是，如何针对主页或静态页面仅检索与搜索对应的帖子列表，而不是搜索结果中的所有其他内容。

我是否需要使用 API 并构建一个 Web 应用来实现此类自定义查询，还是有其他技巧？

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2019年一月17日 01:02 UTC](https://meta.discourse.org/t/custom-tag-query-for-homepage/106658/2 "2019-01-17T01:02:05Z")

</div>

The custom homepage you’re referencing pulls in the topics from a tag using AJAX and an endpoint like this:

[https://meta.discourse.org/tags/theme.json](https://meta.discourse.org/tags/theme.json)

If you want to get the contents of a search (can you clarify what you mean by “all the other stuff”?):

[https://meta.discourse.org/search.json?q=reverse%20engineer&expanded=true](https://meta.discourse.org/search.json?q=reverse%20engineer&expanded=true)

For more details about finding the data that populates a specific page, you can look here:

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2022年一月8日 19:48 UTC](https://meta.discourse.org/t/custom-tag-query-for-homepage/106658/4 "2022-01-08T19:48:40Z")

</div>


