# Het overschrijven van robots.txt opnieuw instellen lijkt niet te werken zoals verwacht

**URL:** https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880
**Category:** Bug
**Created:** [7 december 2023 om 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:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [7 december 2023 om 19:05 UTC](https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880/1 "2023-12-07T19:05:59Z")

</div>

It’s possible to override robots.txt in `/admin/customize/robots` (which is linked in the settings). The page provides a form to have a custom robots.txt. Example:

 ![Screenshot 2023-12-07 at 18.55.37](https://global.discourse-cdn.com/meta/original/4X/5/0/0/500b9b43206d8f2ef30967fbfd46b6f24751c2b7.png)

When pressing that ‘Reset’ button however, the form is immediately filled with what seems to be the website’s own html code and… appears to immediately save that as the new robots.txt

 ![Screenshot 2023-12-07 at 18.53.55](https://global.discourse-cdn.com/meta/original/4X/7/d/7/7d7fcb78d1157f890c6547787c8aaf18b8cb8f28.png)

After a refresh however, it seems to actually have the Discourse’s default robots.txt, so it was reset to the default. But still, that filling with html probably needs a look.

On that note, form reset buttons usually restore the form to initial values (and don’t immediately submit the form), so maybe a “Restore to default robots.txt” link next to the buttons would be more clear.

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [7 december 2023 om 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>

I can reproduce as well!

* * *

To devs: The issue concerns `render_to_string` that renders the template with a default layout. 🤔

> <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>

Here is a solution: adding `, layout: false` param. 👆

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [20 december 2023 om 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>

This should be fixed in:

[https://github.com/discourse/discourse/commit/87883a1963236e919854914b0a02ab1496bb3334](https://github.com/discourse/discourse/commit/87883a1963236e919854914b0a02ab1496bb3334)

Thanks @mentalstring for the report and @Arkshine for pointing out where the problem is!

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [23 december 2023 om 00:00 UTC](https://meta.discourse.org/t/reseting-robots-txt-override-doesnt-seem-to-work-as-expected/287880/6 "2023-12-23T00:00:06Z")

</div>

This topic was automatically closed after 41 hours. New replies are no longer allowed.
