Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🔍️ Fix hreflang annotations on landing pages (#3066)

Luke Vellab91c705d3c09
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx
index c35278135..b56053cbc 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -389,6 +390,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale, path: "/best-doodle-alternative" }),
title: t("doodleAlternativeMetaTitle", {
ns: "home",
}),
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx
index d62c047f1..9148fe07d 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -372,6 +373,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale, path: "/free-scheduling-poll" }),
title: t("freeSchedulingPollMetaTitle", {
ns: "home",
}),
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/committees/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/committees/page.tsx
index 0df314dc4..4ff69eb34 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/committees/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/committees/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -375,6 +376,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale, path: "/scheduling-for/committees" }),
title: t("committeesMetaTitle", {
ns: "home",
defaultValue:
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/executive-assistants/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/executive-assistants/page.tsx
index 23bcf40cd..048e1187c 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/executive-assistants/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/executive-assistants/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -375,6 +376,10 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({
+ locale,
+ path: "/scheduling-for/executive-assistants",
+ }),
title: t("eaMetaTitle", {
ns: "home",
defaultValue:
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/legal/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/legal/page.tsx
index 46d42c4ac..976fd4c39 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/legal/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/legal/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -382,6 +383,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale, path: "/scheduling-for/legal" }),
title: t("legalMetaTitle", {
ns: "home",
defaultValue:
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/sports-clubs/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/sports-clubs/page.tsx
index cd6696c2c..8c67d8c53 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/sports-clubs/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/sports-clubs/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -375,6 +376,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale, path: "/scheduling-for/sports-clubs" }),
title: t("sportsClubsMetaTitle", {
ns: "home",
defaultValue:
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/thesis-defense/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/thesis-defense/page.tsx
index 9b622577a..a934619b2 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/thesis-defense/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/scheduling-for/thesis-defense/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -375,6 +376,10 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({
+ locale,
+ path: "/scheduling-for/thesis-defense",
+ }),
title: t("thesisDefenseMetaTitle", {
ns: "home",
defaultValue:
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx
index 61564da84..245e755c4 100644
--- a/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -389,6 +390,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale, path: "/when2meet-alternative" }),
title: t("when2meetAlternativeMetaTitle", {
ns: "home",
}),
diff --git a/apps/landing/src/app/[locale]/(main)/blog/page.tsx b/apps/landing/src/app/[locale]/(main)/blog/page.tsx
index e9ecc29b3..c3b6fdb56 100644
--- a/apps/landing/src/app/[locale]/(main)/blog/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/blog/page.tsx
@@ -4,6 +4,7 @@ import type { Metadata } from "next";
import { cacheLife } from "next/cache";
import { Trans } from "react-i18next/TransWithoutContext";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getAllPosts } from "@/lib/api";
import { PostPreview } from "./post-preview";
@@ -56,6 +57,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "blog");
return {
+ alternates: getAlternates({ locale, path: "/blog" }),
title: t("blogTitle", {
ns: "blog",
defaultValue: "Rallly - Blog",
diff --git a/apps/landing/src/app/[locale]/(main)/page.tsx b/apps/landing/src/app/[locale]/(main)/page.tsx
index 113b5d0de..42880e4ba 100644
--- a/apps/landing/src/app/[locale]/(main)/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/page.tsx
@@ -22,6 +22,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
export default async function Page(props: {
@@ -395,6 +396,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, "home");
return {
+ alternates: getAlternates({ locale }),
title: t("metaTitle", {
defaultValue: "Rallly: Free Group Meeting Scheduling Tool",
ns: "home",
diff --git a/apps/landing/src/app/[locale]/(main)/pricing/page.tsx b/apps/landing/src/app/[locale]/(main)/pricing/page.tsx
index 733353f4a..1dbcb7a9a 100644
--- a/apps/landing/src/app/[locale]/(main)/pricing/page.tsx
+++ b/apps/landing/src/app/[locale]/(main)/pricing/page.tsx
@@ -32,6 +32,7 @@ import {
SectionTitle,
} from "@/components/section";
import { getTranslation } from "@/i18n/server";
+import { getAlternates } from "@/lib/alternates";
import { getMonthlyPollCount, getMonthlyVoterCount } from "@/lib/data";
import { linkToApp } from "@/lib/linkToApp";
@@ -933,6 +934,7 @@ export async function generateMetadata(props: {
const { locale } = await props.params;
const { t } = await getTranslation(locale, ["common", "pricing"]);
return {
+ alternates: getAlternates({ locale, path: "/pricing" }),
title: t("pricing", { ns: "common", defaultValue: "Pricing" }),
description: t("pricingDescription", {
ns: "pricing",
diff --git a/apps/landing/src/app/sitemap.ts b/apps/landing/src/app/sitemap.ts
index fee2e3d01..0ded6ef24 100644
--- a/apps/landing/src/app/sitemap.ts
+++ b/apps/landing/src/app/sitemap.ts
@@ -1,11 +1,8 @@
-import { supportedLngs } from "@rallly/languages";
import { absoluteUrl } from "@rallly/utils/absolute-url";
import type { MetadataRoute } from "next";
-
+import { getAlternateLanguages } from "@/lib/alternates";
import { getAllPosts } from "@/lib/api";
-const alternateLanguages = supportedLngs.filter((lng) => lng !== "en");
-
const seoPages = [
"/best-doodle-alternative",
"/scheduling-for/executive-assistants",
@@ -17,13 +14,6 @@ const seoPages = [
"/when2meet-alternative",
];
-const getAlternateLanguages = (path: string) => {
- return alternateLanguages.reduce<Record<string, string>>((acc, locale) => {
- acc[locale] = absoluteUrl(`/${locale}${path}`);
- return acc;
- }, {});
-};
-
export default async function Sitemap(): Promise<MetadataRoute.Sitemap> {
const posts = getAllPosts(["slug"]);
diff --git a/apps/landing/src/lib/alternates.ts b/apps/landing/src/lib/alternates.ts
new file mode 100644
index 000000000..5ec454d43
--- /dev/null
+++ b/apps/landing/src/lib/alternates.ts
@@ -0,0 +1,30 @@
+import { supportedLngs } from "@rallly/languages";
+import { absoluteUrl } from "@rallly/utils/absolute-url";
+import type { Metadata } from "next";
+
+const localizedUrl = (locale: string, path: string) =>
+ // `/en/*` redirects to `/*`, so English lives at the unprefixed URL
+ locale === "en" ? absoluteUrl(path) : absoluteUrl(`/${locale}${path}`);
+
+export function getAlternateLanguages(path = "/") {
+ const languages: Record<string, string> = {
+ "x-default": absoluteUrl(path),
+ };
+ for (const locale of supportedLngs) {
+ languages[locale] = localizedUrl(locale, path);
+ }
+ return languages;
+}
+
+export function getAlternates({
+ locale,
+ path = "/",
+}: {
+ locale: string;
+ path?: string;
+}): Metadata["alternates"] {
+ return {
+ canonical: localizedUrl(locale, path),
+ languages: getAlternateLanguages(path),
+ };
+}