From fcc6afb4bdfb0ccfa8f8261db951ce6ccc3dc2b5 Mon Sep 17 00:00:00 2001 From: Lacey Williams Henschel Date: Mon, 11 Sep 2023 15:26:37 -0700 Subject: [PATCH] Add SEO title, desc, author to library pages --- libraries/views.py | 12 ++++++++++++ templates/base.html | 2 +- templates/libraries/category_list.html | 4 +++- templates/libraries/detail.html | 6 ++++++ templates/libraries/flat_list.html | 4 +++- templates/libraries/list.html | 3 ++- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/libraries/views.py b/libraries/views.py index e777e08f..c4ac8897 100644 --- a/libraries/views.py +++ b/libraries/views.py @@ -159,6 +159,7 @@ class LibraryDetail(FormMixin, DetailView): context["documentation_url"] = self.get_documentation_url(context["version"]) context["github_url"] = self.get_github_url(context["version"]) context["maintainers"] = self.get_maintainers(context["version"]) + context["author_tag"] = self.get_author_tag() # Populate the commit graphs context["commit_data_annual"] = self.get_commit_data_annual() @@ -190,6 +191,17 @@ class LibraryDetail(FormMixin, DetailView): raise Http404("No library found matching the query") return obj + def get_author_tag(self): + """Format the authors for the author meta tag in the template.""" + authors = self.object.authors.all() + author_names = [author.get_full_name() for author in authors] + if len(author_names) > 1: + final_output = ", ".join(author_names[:-1]) + " and " + author_names[-1] + else: + final_output = author_names[0] if author_names else "" + + return final_output + def _prepare_commit_data(self, commit_data, data_type): commit_data_list = [] for data in commit_data: diff --git a/templates/base.html b/templates/base.html index c4878cf4..34143203 100644 --- a/templates/base.html +++ b/templates/base.html @@ -28,7 +28,7 @@ - + diff --git a/templates/libraries/category_list.html b/templates/libraries/category_list.html index d94ef190..e3eb89e3 100644 --- a/templates/libraries/category_list.html +++ b/templates/libraries/category_list.html @@ -2,7 +2,9 @@ {% load i18n %} {% load static %} -{% block title %}{% trans "Libraries by Category" %}{% endblock %} +{% block title %}{% trans "Boost Libraries by Category" %}{% endblock %} +{% block description %}{% trans "Browse Boost C++ Libraries by category and discover tools for multithreading, image processing, testing, and more." %}{% endblock %} + {% block content %}
diff --git a/templates/libraries/detail.html b/templates/libraries/detail.html index cf0c9fef..e5d025a1 100644 --- a/templates/libraries/detail.html +++ b/templates/libraries/detail.html @@ -1,5 +1,11 @@ {% extends "base.html" %} +{% load i18n %} {% load static %} + +{% block title %}Boost.{{ object.name }} ({{ version.display_name }}){% endblock %} +{% block description %}{% trans object.description %}{% endblock %} +{% block author %}{{ author_tag }}{% endblock %} + {% block content %}
diff --git a/templates/libraries/list.html b/templates/libraries/list.html index d92df54a..2da1e454 100644 --- a/templates/libraries/list.html +++ b/templates/libraries/list.html @@ -2,7 +2,8 @@ {% load i18n %} {% load static %} -{% block title %}{% trans "Libraries" %}{% endblock %} +{% block title %}{% trans "Boost Libraries" %}{% endblock %} +{% block description %}{% trans "Explore our comprehensive list of Boost C++ Libraries and discover tools for multithreading, image processing, testing, and more." %}{% endblock %} {% block content %}