diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb
index ed817508c96..54d030d1106 100644
--- a/app/views/topics/show.html.erb
+++ b/app/views/topics/show.html.erb
@@ -51,7 +51,7 @@
<% end %>
- <% if @topic_view.posts&.first && !@topic_view.posts.first.is_first_post? %>
+ <% if @topic_view.crawler_posts&.first && !@topic_view.crawler_posts.first.is_first_post? %>
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index 72fd06a49af..1cd6db32c1a 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -5261,6 +5261,23 @@ RSpec.describe TopicsController do
)
end
+ it "includes top-level author metadata when the view does not include the OP naturally" do
+ get "#{topic.relative_url}/2"
+ expect(body).to have_tag(
+ "[itemtype='http://schema.org/DiscussionForumPosting'] > [itemprop='author']",
+ )
+
+ get "#{topic.relative_url}/27"
+ expect(body).to have_tag(
+ "[itemtype='http://schema.org/DiscussionForumPosting'] > [itemprop='author']",
+ )
+
+ get "#{topic.relative_url}?page=2"
+ expect(body).to have_tag(
+ "[itemtype='http://schema.org/DiscussionForumPosting'] > [itemprop='author']",
+ )
+ end
+
context "with canonical_url" do
fab!(:topic_embed) { Fabricate(:topic_embed, embed_url: "https://markvanlan.com") }
let!(:user_agent) do