# 将 docs 类添加到 body 标签

**URL:** <https://meta.discourse.org/t/add-docs-class-to-body-tag/230410>\
**Category:** Feature\
**Tags:** docs\
**Created:** [2022年五月20日 08:44 UTC](https://meta.discourse.org/t/add-docs-class-to-body-tag/230410 "2022-05-20T08:44:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pipkin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pipkin/32/134643_2.png) [@pipkin](https://meta.discourse.org/u/pipkin)\
**Post date:** [2022年五月20日 08:44 UTC](https://meta.discourse.org/t/add-docs-class-to-body-tag/230410/1 "2022-05-20T08:44:29Z")

</div>

功能请求：

能否在 `/docs` 页面的 `<body>` 标签中添加一个 `docs` 类？

这样就可以使用 CSS 仅自定义 docs 页面的标题。

已通过一种丑陋的方式解决：

```javascript
<script type="text/discourse-plugin" version="0.8">
api.onPageChange((url) => {
  if(window.location.pathname == "/docs") {
    document.querySelector("body").classList.add("docs");
  }
  else {
    document.querySelector("body").classList.remove("docs");
  }
})
</script>

```

放在这里：

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/0/c/c0ca10a2e21aade891cd96f4da55af46b076dbbf.png)
