diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 3196fa1cb24..14687f789a7 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -121,6 +121,7 @@ class GroupsController < ApplicationController format.html do @title = group.full_name.present? ? group.full_name.capitalize : group.name + @full_title = "#{@title} - #{SiteSetting.title}" @description_meta = group.bio_cooked.present? ? PrettyText.excerpt(group.bio_cooked, 300) : @title render :show end diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb index cc250d46849..e0e82db743a 100644 --- a/app/views/groups/show.html.erb +++ b/app/views/groups/show.html.erb @@ -1,3 +1,5 @@ +<% content_for :title do %><%= @full_title %><% end %> + <% content_for :head do %> <%= raw crawlable_meta_data(title: @title, description: @description_meta) %> <% end %> diff --git a/spec/components/retrieve_title_spec.rb b/spec/components/retrieve_title_spec.rb index a519e7eb722..b7a5b3f8822 100644 --- a/spec/components/retrieve_title_spec.rb +++ b/spec/components/retrieve_title_spec.rb @@ -33,7 +33,7 @@ describe RetrieveTitle do expect(title).to eq("Good Title") end - it "will prefer the title from an opengraph tag" do + it "will prefer the title over the opengraph tag" do title = RetrieveTitle.extract_title(<<~HTML Good Title diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index 340376607af..4b0e22a2685 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -411,6 +411,7 @@ describe GroupsController do expect(response.status).to eq(200) + expect(response.body).to have_tag "title", text: "#{group.name} - #{SiteSetting.title}" expect(response.body).to have_tag(:meta, with: { property: 'og:title', content: group.name })