From 61c6d2a7fc462c7d56f7ab1e56b8643de0df7f8d Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Tue, 28 May 2024 12:59:24 +0800 Subject: [PATCH] DEV: Also noindex embedded comments (#27221) For some reason, despite iframe also indicating a ``` ``` .. Google is still indexing the embed/comment URLs. This causes links like http://\/embed/comments\?topic_id\=6366 to be indexed instead of the topic. This commit adds it explicitly in the header. --- app/controllers/embed_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index 8974e4be1b6..b0bd5893997 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -85,13 +85,13 @@ class EmbedController < ApplicationController raise Discourse::InvalidAccess.new("invalid embed host") end - topic_id = nil if embed_url.present? topic_id = TopicEmbed.topic_id_for_embed(embed_url) else topic_id = params[:topic_id].to_i end + response.headers["X-Robots-Tag"] = "noindex, indexifembedded" if topic_id @topic_view = TopicView.new(