Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Enable Markdown endpoints by default (#43915)

Penar Musaraj5e5f1df030b8
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index eb9d2ff1179..24f92ba3c0d 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -3178,7 +3178,7 @@ en:
enable_invite_modal_with_roles: "Enables a redesigned invite flow that lets admins invite someone directly as an admin. The invitee becomes a moderator on signup and an admin once the inviter confirms via email."
update_pending_users_reminder_default: "We are updating the default for the {{setting:pending_users_reminder_delay_minutes}} setting to 30 minutes so that staff are promptly notified when a new member is waiting for approval. If you have previously changed this setting, this change will have no effect."
enable_generated_llms_txt: "Generates a concise /llms.txt when no custom file is uploaded. The document describes public discovery routes, the preferred Discourse MCP interface, and responsible agent access. To tune automated access, configure {{setting:slow_down_crawler_user_agents}} and {{setting:slow_down_crawler_rate}}."
- experimental_markdown_endpoints: "Serve supported topics and topic lists as Markdown through .md URLs and Accept negotiation. Normal visibility and profile privacy rules always apply."
+ enable_markdown_endpoints: "Serve supported topics and topic lists as Markdown through .md URLs and requests with an Accept: text/markdown header. Normal visibility and profile privacy rules always apply."
errors:
invalid_css_color: "Invalid color. Enter a color name or hex value."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index d084fe6e102..9e85fc47477 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -4781,10 +4781,16 @@ dashboard:
client: true
experimental:
- experimental_markdown_endpoints:
+ enable_markdown_endpoints:
default: false
hidden: true
- area: "experimental"
+ client: true
+ upcoming_change:
+ status: "beta"
+ impact: "feature,all_members"
+ learn_more_url: "https://meta.discourse.org/t/-/413006"
+ allow_enabled_for:
+ - everyone
enable_generated_llms_txt:
default: false
hidden: true
diff --git a/db/migrate/20260921120000_rename_experimental_markdown_endpoints.rb b/db/migrate/20260921120000_rename_experimental_markdown_endpoints.rb
new file mode 100644
index 00000000000..60fed8adc39
--- /dev/null
+++ b/db/migrate/20260921120000_rename_experimental_markdown_endpoints.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RenameExperimentalMarkdownEndpoints < ActiveRecord::Migration[8.0]
+ def up
+ execute(<<~SQL)
+ UPDATE site_settings
+ SET name = 'enable_markdown_endpoints'
+ WHERE name = 'experimental_markdown_endpoints'
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ UPDATE site_settings
+ SET name = 'experimental_markdown_endpoints'
+ WHERE name = 'enable_markdown_endpoints'
+ SQL
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 9f754a39397..5c10b624468 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -25405,6 +25405,7 @@ ALTER TABLE ONLY public.ad_plugin_house_ads_groups
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
+('20260921120000'),
('20260921081150'),
('20260921074918'),
('20260921015711'),
diff --git a/lib/markdown_endpoint/controller_support.rb b/lib/markdown_endpoint/controller_support.rb
index fcf15174a05..f310baa7cc4 100644
--- a/lib/markdown_endpoint/controller_support.rb
+++ b/lib/markdown_endpoint/controller_support.rb
@@ -48,7 +48,7 @@ module MarkdownEndpoint
end
def markdown_alternate_url
- return unless SiteSetting.experimental_markdown_endpoints
+ return unless SiteSetting.enable_markdown_endpoints
path = markdown_alternate_path
return if path.blank?
@@ -79,7 +79,7 @@ module MarkdownEndpoint
return if request.path.end_with?(".md")
accept = request.headers["Accept"]
- if SiteSetting.experimental_markdown_endpoints && markdown_supported_response? &&
+ if SiteSetting.enable_markdown_endpoints && markdown_supported_response? &&
AcceptHeader.preferred?(accept)
return
end
diff --git a/lib/markdown_endpoint/request_constraint.rb b/lib/markdown_endpoint/request_constraint.rb
index 749d9556908..282b89c8d69 100644
--- a/lib/markdown_endpoint/request_constraint.rb
+++ b/lib/markdown_endpoint/request_constraint.rb
@@ -9,7 +9,7 @@ module MarkdownEndpoint
end
def matches?(request)
- return false unless SiteSetting.experimental_markdown_endpoints
+ return false unless SiteSetting.enable_markdown_endpoints
return true unless @accept
return false if request.path.end_with?(".json", ".rss")
diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rb
index 32eb44fb579..52c285698dc 100644
--- a/spec/requests/application_controller_spec.rb
+++ b/spec/requests/application_controller_spec.rb
@@ -1964,7 +1964,7 @@ RSpec.describe ApplicationController do
it "is not included by default" do
get "/latest"
expect(response.status).to eq(200)
- expect(response.headers["Link"]).to eq(nil)
+ expect(response.headers["Link"].to_s).not_to include("rel=preconnect", 'rel="preload"')
end
context "when in preconnect mode" do
@@ -1984,7 +1984,7 @@ RSpec.describe ApplicationController do
expect(response.headers["X-Discourse-Early-Hint"]).to include(
"<https://cdn.example.com>; rel=preconnect",
)
- expect(response.headers["Link"]).to eq(nil)
+ expect(response.headers["Link"].to_s).not_to include("rel=preconnect", 'rel="preload"')
end
it "is skipped for non-app URLs" do
diff --git a/spec/requests/markdown_directories_spec.rb b/spec/requests/markdown_directories_spec.rb
index 8fb8b40151f..763eaaffafd 100644
--- a/spec/requests/markdown_directories_spec.rb
+++ b/spec/requests/markdown_directories_spec.rb
@@ -9,10 +9,7 @@ RSpec.describe "Markdown directories" do
Fabricate(:tag, public_topic_count: 1, staff_topic_count: 1, description: "A useful tag.")
end
- before do
- SiteSetting.experimental_markdown_endpoints = true
- SiteSetting.tagging_enabled = true
- end
+ before { SiteSetting.tagging_enabled = true }
after { category.clear_url_cache }
@@ -210,7 +207,7 @@ RSpec.describe "Markdown directories" do
end
it "keeps directories behind the Markdown feature setting" do
- SiteSetting.experimental_markdown_endpoints = false
+ SiteSetting.enable_markdown_endpoints = false
%w[categories tags].each do |directory|
get "/#{directory}.md"
expect(response).to have_http_status(:not_found)
diff --git a/spec/requests/markdown_endpoints_spec.rb b/spec/requests/markdown_endpoints_spec.rb
index 38b89c62f3b..9b927f6fd21 100644
--- a/spec/requests/markdown_endpoints_spec.rb
+++ b/spec/requests/markdown_endpoints_spec.rb
@@ -10,14 +10,32 @@ RSpec.describe "Markdown endpoints" do
end
fab!(:post) { Fabricate(:post, topic: topic, user: user, raw: "Visible body") }
- before { SiteSetting.experimental_markdown_endpoints = true }
after { category.clear_url_cache }
+ it "respects the upcoming change promotion policy and explicit opt-in" do
+ SiteSetting.promote_upcoming_changes_on_status = "stable"
+
+ get "/latest.md"
+ expect(response).to have_http_status(:not_found)
+
+ get "/latest", headers: { "ACCEPT" => "text/html" }
+ expect(response.headers["Link"]).to be_blank
+
+ SiteSetting.enable_markdown_endpoints = true
+
+ get "/latest.md"
+ expect(response).to have_http_status(:ok)
+ expect(response.media_type).to eq("text/markdown")
+
+ get "/latest", headers: { "ACCEPT" => "text/html" }
+ expect(response.headers["Link"]).to include("/latest.md")
+ end
+
it "keeps HTML tag-intersection redirects out of Markdown routes" do
tag = Fabricate(:tag)
[false, true].each do |enabled|
- SiteSetting.experimental_markdown_endpoints = enabled
+ SiteSetting.enable_markdown_endpoints = enabled
get "/tags/intersection/#{tag.name}/#{tag.name}", headers: { "ACCEPT" => "text/html" }
expect(response).to redirect_to("/tag/#{tag.name}")
follow_redirect!
@@ -848,7 +866,7 @@ RSpec.describe "Markdown endpoints" do
end
it "keeps Markdown routes and discovery absent while disabled" do
- SiteSetting.experimental_markdown_endpoints = false
+ SiteSetting.enable_markdown_endpoints = false
sign_in(user)
%w[/new /unread].each do |path|