# 重置 robots.txt 覆盖似乎没有按预期工作

**URL:** <https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880>\
**Category:** Bug\
**Created:** [2023 年12 月 7 日 19:05 UTC](https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880 "2023-12-07T19:05:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

作者： ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
发布日期： [2023 年12 月 7 日 20:24 UTC](https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880/2 "2023-12-07T20:24:41Z")

</div>

我也能重现！

* * *

致开发者：该问题与 `render_to_string` 有关，它会使用默认布局渲染模板。 🤔

> <https://github.com/discourse/discourse/blob/main/app/controllers/admin/robots_txt_controller.rb#L15-L18>

> <https://github.com/discourse/discourse/blob/main/app/controllers/admin/robots_txt_controller.rb#L29-L35>

这里有一个解决方案：添加 `, layout: false` 参数。 👆

---

_[View the full topic](https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880)._
