من الممكن تجاوز ملف robots.txt في /admin/customize/robots (والذي يمكن الوصول إليه من الإعدادات). توفر الصفحة نموذجًا لملف robots.txt مخصص. مثال:
عند الضغط على زر “إعادة تعيين” هذا، يتم ملء النموذج على الفور بما يبدو أنه رمز HTML الخاص بالموقع… ويبدو أنه يتم حفظه على الفور كملف robots.txt جديد.
بعد التحديث، يبدو أنه يحتوي بالفعل على ملف robots.txt الافتراضي الخاص بـ Discourse، لذلك تمت إعادة تعيينه إلى الافتراضي. ولكن لا يزال، هذا الملء برمز HTML يحتاج إلى مراجعة على الأرجح.
في هذا الصدد، عادةً ما تعيد أزرار إعادة تعيين النموذج النموذج إلى القيم الأولية (ولا ترسل النموذج على الفور)، لذا ربما يكون رابط “استعادة إلى ملف robots.txt الافتراضي” بجوار الأزرار أكثر وضوحًا.
3 إعجابات
يمكنني تكرار ذلك أيضًا!
للمطورين: تتعلق المشكلة بـ render_to_string الذي يعرض القالب مع تخطيط افتراضي.
def original_robots_txt
if SiteSetting.allow_index_in_robots_txt?
@robots_info = ::RobotsTxtController.fetch_default_robots_info
render_to_string "robots_txt/index", layout: false
else
render_to_string "robots_txt/no_index", layout: false
end
إليك حل: إضافة المعلمة , layout: false.
4 إعجابات
Osama
20 ديسمبر 2023، 8:44م
4
يجب إصلاح هذا في:
committed 08:00PM - 20 Dec 23 UTC
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 على الإشارة إلى مكان المشكلة!
4 إعجابات
nat
(Natalie T)
تم إغلاقه في
23 ديسمبر 2023، 12:00ص
6
تم إغلاق هذا الموضوع تلقائيًا بعد 41 ساعة. لم يعد يُسمح بالردود الجديدة.