Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic page titles #503

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dschwindt
Copy link
Contributor

@dschwindt dschwindt commented Nov 22, 2021

This PR closes #501

What does this PR do?

When a user navigates to a different page on the site, this code dynamically updates the page titles in English and Spanish using react-helmet and react-i18next so that the titles can be reflected in analytics. The code also includes a description for the home page for SEO in both languages.

How does this PR make you feel? 馃敆

dog in helmet

@netlify
Copy link

netlify bot commented Nov 22, 2021

馃懛 Deploy request for upswyng accepted.

馃敤 Explore the source changes: 2bf51fe

馃攳 Inspect the deploy log: https://app.netlify.com/sites/upswyng/deploys/619bc578ef736a0007887a67

@@ -51,6 +52,9 @@ const CategoryResults = ({

return (
<>
<Helmet>
<title>{t(categoryTranslationKey)} - Upswyng</title>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on creating a utility that centralized appending the "- UpSwyng" to the title? Could create something like seo.js in the utils folder and create a makePageTitle that accepts a string as an argument and just returns that appended with - UpSwyng.

import HomeButtons from "./HomeButtons";
import React from "react";
import SearchForm from "./SearchForm";
import { useTranslation } from "react-i18next";

const Home = () => {
const { t } = useTranslation("footer");
const { t } = useTranslation(["footer", "home"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another options could be removing the specific name space here and just applying it within the t function, e.g.:

const { t } = useTranslation();

// ...other stuff in between

<Helmet>
   <title>{t("home.title")}</title>
   <meta name="description" content={t("home.description")} />
</Helmet>

NBD either way but thought this may be a bit easier to read.

@jacobvenable
Copy link
Member

Looking good! I think we should try to add a utility that automatically appends - UpSwyng to each title, but otherwise everything looks great!

@jacobvenable
Copy link
Member

鈩癸笍 Heads up to anyone who stumbles on this PR.

I was made aware that this developer won't be able to finish this ticket and will be taking on my minor nits. I appreciate @dschwindt for getting it this far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement dynamic page titles
2 participants