chore: give projects, orgs, and collections canonical URLs to hopefully improve SEO (#6014)
* Give projects, collections, and orgs canonical URLs * prepr
This commit is contained in:
@@ -2317,6 +2317,18 @@ const canCreateServerFrom = computed(() => {
|
|||||||
return project.value.project_type === 'modpack' && project.value.server_side !== 'unsupported'
|
return project.value.project_type === 'modpack' && project.value.server_side !== 'unsupported'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const createCanonicalUrl = () =>
|
||||||
|
project.value ? `https://modrinth.com/project/${project.value.id}` : undefined
|
||||||
|
|
||||||
|
useHead({
|
||||||
|
link: [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: createCanonicalUrl,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
if (!route.name.startsWith('type-id-settings')) {
|
if (!route.name.startsWith('type-id-settings')) {
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: () => title.value,
|
title: () => title.value,
|
||||||
@@ -2324,6 +2336,7 @@ if (!route.name.startsWith('type-id-settings')) {
|
|||||||
ogTitle: () => title.value,
|
ogTitle: () => title.value,
|
||||||
ogDescription: () => project.value?.description ?? '',
|
ogDescription: () => project.value?.description ?? '',
|
||||||
ogImage: () => project.value?.icon_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
ogImage: () => project.value?.icon_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
||||||
|
ogUrl: createCanonicalUrl,
|
||||||
robots: () =>
|
robots: () =>
|
||||||
project.value?.status === 'approved' || project.value?.status === 'archived'
|
project.value?.status === 'approved' || project.value?.status === 'archived'
|
||||||
? 'all'
|
? 'all'
|
||||||
@@ -2332,6 +2345,7 @@ if (!route.name.startsWith('type-id-settings')) {
|
|||||||
} else {
|
} else {
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
robots: 'noindex',
|
robots: 'noindex',
|
||||||
|
ogUrl: createCanonicalUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -657,6 +657,7 @@ watch(
|
|||||||
[collection, creator],
|
[collection, creator],
|
||||||
([col, cre]) => {
|
([col, cre]) => {
|
||||||
if (col && cre) {
|
if (col && cre) {
|
||||||
|
const canonicalUrl = col ? `https://modrinth.com/collection/${col.id}` : undefined
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: formatMessage(messages.collectionTitle, { name: col.name }),
|
title: formatMessage(messages.collectionTitle, { name: col.name }),
|
||||||
description: formatMessage(messages.collectionDescription, {
|
description: formatMessage(messages.collectionDescription, {
|
||||||
@@ -667,8 +668,17 @@ watch(
|
|||||||
ogTitle: formatMessage(messages.collectionTitle, { name: col.name }),
|
ogTitle: formatMessage(messages.collectionTitle, { name: col.name }),
|
||||||
ogDescription: col.description,
|
ogDescription: col.description,
|
||||||
ogImage: col.icon_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
ogImage: col.icon_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
||||||
|
ogUrl: canonicalUrl,
|
||||||
robots: col.status === 'listed' ? 'all' : 'noindex',
|
robots: col.status === 'listed' ? 'all' : 'noindex',
|
||||||
})
|
})
|
||||||
|
useHead({
|
||||||
|
link: [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: canonicalUrl,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
|
|||||||
@@ -551,6 +551,7 @@ watch(
|
|||||||
if (org) {
|
if (org) {
|
||||||
const title = `${org.name} - Organization`
|
const title = `${org.name} - Organization`
|
||||||
const description = `${org.description} - View the organization ${org.name} on Modrinth`
|
const description = `${org.description} - View the organization ${org.name} on Modrinth`
|
||||||
|
const canonicalUrl = org ? `https://modrinth.com/organization/${org.id}` : undefined
|
||||||
|
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title,
|
title,
|
||||||
@@ -558,6 +559,15 @@ watch(
|
|||||||
ogTitle: title,
|
ogTitle: title,
|
||||||
ogDescription: org.description,
|
ogDescription: org.description,
|
||||||
ogImage: org.icon_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
ogImage: org.icon_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
||||||
|
ogUrl: canonicalUrl,
|
||||||
|
})
|
||||||
|
useHead({
|
||||||
|
link: [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: canonicalUrl,
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user