> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI0ODgzOWNjMy1lYWViLTRiM2QtYTYyMy02ZDMyY2VlNWMxMjMiLCJleHAiOjE3NzgzMjEzMzQsImlhdCI6MTc3ODMyMTAzNH0.Q9NnMtpqdfLKziXMdgZ2T_lNsyMNrfgyb2N7jT6V4Ho
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 为文档添加公告横幅

公告横幅是吸引用户关注新功能和产品发布的绝佳方式。配置后，公告栏会出现在文档站点的顶部。用户关闭横幅后，下次更新公告时它会重新出现。

```yaml docs.yml
announcement:
    message: "🚀 新功能：公告功能已上线！(<a href=\"https://buildwithfern.com/learn/docs/customization/announcement-banner\" target=\"_blank\">了解更多</a>) 🚀"
```

公告消息支持 Markdown 和 HTML。您可以包含链接、图片和其他格式。可以使用[自定义 CSS](/docs/customization/custom-css-js#custom-css) 来自定义公告的样式。

## 在多个级别配置公告

可以在多个级别配置公告，以针对特定产品或版本。优先级层次结构为：

1. **版本级别** - 最高优先级，为特定版本定义时始终显示
2. **产品级别** - 当产品没有版本级别公告时使用
3. **配置级别** - 当没有定义特定覆盖时，在所有产品/版本中显示的后备公告

将 `announcement` 属性直接添加到 `docs.yml` 文件中 `products:` 或 `versions:` 列表的项目中。

下面的示例显示了一个多产品文档站点，其中 Docs 产品显示"Docs 产品处于测试阶段"，SDKs v1 版本显示"v1 处于维护模式"，而 SDKs v2 版本继承产品级别的消息"新 SDK 功能已上线！"

```yaml docs.yml
# 配置级别公告（所有产品/版本的后备）
announcement:
  message: "欢迎使用我们的文档！"

products:
  - display-name: Docs
    path: ./products/docs/docs.yml
    # 产品级别公告（为此产品覆盖配置级别）
    announcement:
      message: "Docs 产品处于测试阶段。功能可能会发生变化。"

  - display-name: SDKs
    path: ./products/sdks/sdks.yml
    announcement:
      message: "新 SDK 功能已上线！"
    
    versions:
      - display-name: v1
        path: ./products/sdks/v1/docs.yml
        # 版本级别公告（最高优先级，覆盖产品和配置级别）
        announcement:
          message: "v1 处于维护模式。请升级到 v2。"
      
      - display-name: v2
        path: ./products/sdks/v2/docs.yml
        # 此版本将显示产品级别的公告
```