# 重置 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:** 4

<div class="post-metadata">

作者： ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)\
发布日期： [2023 年12 月 20 日 20:44 UTC](https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880/4 "2023-12-20T20:44:34Z")

</div>

这应该已修复：

> <https://github.com/discourse/discourse/commit/87883a1963236e919854914b0a02ab1496bb3334>
>
> Meta topic: https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-see…m-to-work-as-expected/287880?u=osama
> 
> Discourse provides a default version for \`/robots.txt\` which can be customized by admins in \`/admin/customize/robots\`. In that page, there's a button to reset back to the default version that Discourse provides. However, there's currently a bug with the reset button where the content appears to change to some HTML document instead of the default \`robots.txt\` version when clicking the button. Refreshing the page shows the true/correct content of \`robots.txt\` which is the default version, so the reset button actually works but there's a display problem.
> 
> What causes this display problem is that we use Rails' \`render\_to\_string\` method to generate the default content for \`robots.txt\` from the template, and what we get from that method is the \`robots.txt\` content wrapped in the application layout. To fix this issue, we need to pass \`layout: false\` to the \`render\_to\_string\` method so that it renders the template without any layouts.

感谢 @mentalstring 的报告和 @Arkshine 指出问题所在！

---

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