Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaky-regions-spend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apostrophecms/seo": major

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not major.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed.

---

Removes the `seoSiteCanonicalUrl` field from global settings. The base URL is now derived automatically from `APOS_BASE_URL` or the `baseUrl` option. The value remains available at `req.data.global.seoSiteCanonicalUrl` for backwards compatibility.
2 changes: 0 additions & 2 deletions packages/seo/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"siteNameHelp": "Der Name Ihrer Website (verwendet in strukturierten Daten und beim Teilen in sozialen Netzwerken).",
"siteDescription": "Website-Beschreibung",
"siteDescriptionHelp": "Eine kurze Beschreibung Ihrer Website.",
"siteCanonicalUrl": "Basis-URL der Website",
"siteCanonicalUrlHelp": "Die Basis-URL Ihrer Website (z. B. https://example.com). Erforderlich für korrekte kanonische Links und strukturierte Daten.",

"themeColor": "Mobile Themenfarbe",
"themeColorHelp": "Legen Sie die Farbe der Browser-Oberfläche für Mobilgeräte und PWAs fest.",
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"siteNameHelp": "The name of your website (used in structured data and social sharing).",
"siteDescription": "Site Description",
"siteDescriptionHelp": "A brief description of your website.",
"siteCanonicalUrl": "Site Base URL",
"siteCanonicalUrlHelp": "The base URL of your site (e.g., https://example.com). Required for proper canonical links and structured data.",

"themeColor": "Mobile Theme Color",
"themeColorHelp": "Set the browser chrome color for mobile devices and PWAs.",
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"siteNameHelp": "El nombre de su sitio web (usado en datos estructurados y en redes sociales).",
"siteDescription": "Descripción del sitio",
"siteDescriptionHelp": "Una breve descripción de su sitio web.",
"siteCanonicalUrl": "URL base del sitio",
"siteCanonicalUrlHelp": "La URL base de su sitio (ej. https://example.com). Requerida para enlaces canónicos y datos estructurados correctos.",

"themeColor": "Color del tema móvil",
"themeColorHelp": "Establezca el color de la interfaz del navegador en dispositivos móviles y PWAs.",
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"siteNameHelp": "Le nom de votre site web (utilisé dans les données structurées et le partage sur les réseaux sociaux).",
"siteDescription": "Description du site",
"siteDescriptionHelp": "Brève description de votre site web.",
"siteCanonicalUrl": "URL de base du site",
"siteCanonicalUrlHelp": "L’URL de base de votre site (ex. https://example.com). Nécessaire pour des liens canoniques et des données structurées corrects.",

"themeColor": "Couleur du thème mobile",
"themeColorHelp": "Définissez la couleur de l’interface du navigateur sur les appareils mobiles et les PWA.",
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"siteNameHelp": "Il nome del tuo sito web (usato nei dati strutturati e nella condivisione sui social).",
"siteDescription": "Descrizione del sito",
"siteDescriptionHelp": "Breve descrizione del tuo sito web.",
"siteCanonicalUrl": "URL base del sito",
"siteCanonicalUrlHelp": "L’URL base del tuo sito (es. https://example.com). Necessario per i link canonici e i dati strutturati corretti.",

"themeColor": "Colore tema mobile",
"themeColorHelp": "Imposta il colore dell’interfaccia del browser per dispositivi mobili e PWA.",
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"siteNameHelp": "O nome do seu site (usado em dados estruturados e compartilhamento em redes sociais).",
"siteDescription": "Descrição do site",
"siteDescriptionHelp": "Uma breve descrição do seu site.",
"siteCanonicalUrl": "URL base do site",
"siteCanonicalUrlHelp": "A URL base do seu site (ex.: https://example.com). Necessária para links canônicos e dados estruturados corretos.",

"themeColor": "Cor do tema móvel",
"themeColorHelp": "Defina a cor da interface do navegador para dispositivos móveis e PWAs.",
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/i18n/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"siteNameHelp": "Názov vašej webovej stránky (používa sa v štruktúrovaných dátach a pri zdieľaní na sociálnych sieťach).",
"siteDescription": "Popis stránky",
"siteDescriptionHelp": "Stručný popis vašej webovej stránky.",
"siteCanonicalUrl": "Základná URL stránky",
"siteCanonicalUrlHelp": "Základná URL vašej stránky (napr. https://example.com). Potrebné pre správne kanonické odkazy a štruktúrované dáta.",

"themeColor": "Farba témy pre mobil",
"themeColorHelp": "Nastavte farbu rozhrania prehliadača pre mobilné zariadenia a PWA.",
Expand Down
8 changes: 0 additions & 8 deletions packages/seo/lib/jsonld-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,14 +983,6 @@ class JsonLdSchemaHandler {
if (fromGlobal) {
return fromGlobal.replace(/\/$/, '');
}
const abs = data.req?.absoluteUrl;

if (abs) {
try {
return new URL(abs).origin;
} catch (e) { }
}

return null;
}

Expand Down
20 changes: 12 additions & 8 deletions packages/seo/modules/@apostrophecms/seo-fields-global/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ module.exports = {
textarea: true,
help: 'aposSeo:siteDescriptionHelp'
},
seoSiteCanonicalUrl: {
label: 'aposSeo:siteCanonicalUrl',
type: 'url',
required: true,
help: 'aposSeo:siteCanonicalUrlHelp'
},
seoJsonLdOrganization: {
label: 'aposSeo:organizationInfo',
type: 'object',
Expand Down Expand Up @@ -333,7 +327,6 @@ module.exports = {
'llmsCustomText',
'seoSiteName',
'seoSiteDescription',
'seoSiteCanonicalUrl',
'seoJsonLdOrganization',
'seoSocialProfiles',
'seoSearchQueryParam'
Expand Down Expand Up @@ -375,6 +368,17 @@ module.exports = {
: null;
},

extendMethods(self) {
return {
async addGlobalToData(_super, req) {
await _super(req);
// For bc. Prefer self.apos.url.getBaseUrl(req) or the ._url
// property of the document in question.
req.data.global.seoSiteCanonicalUrl = self.apos.url.getBaseUrl(req);
}
};
},

handlers(self) {
return {
'@apostrophecms/url:getAllUrlMetadata': {
Expand Down Expand Up @@ -533,7 +537,7 @@ Allow: /
return global.llmsCustomText;
}

const baseUrl = global?.seoSiteCanonicalUrl || req.absoluteUrl.split('/').slice(0, 3).join('/');
const baseUrl = self.apos.url.getBaseUrl(req);

// Build the LLMS.txt content
let content = `# ${global.seoSiteName || global.title || 'Website'}\n\n`;
Expand Down
10 changes: 3 additions & 7 deletions packages/seo/test/functional-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
apos = await t.create({
root: module,
testModule: true,
baseUrl: 'http://localhost:3000',
modules: getAppConfig()
});
});
Expand All @@ -37,7 +38,6 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
{ _id: global._id },
{
$set: {
seoSiteCanonicalUrl: 'https://example.com',
seoSiteName: 'Example Tech Corp',
seoSiteDescription: 'Leading provider of tech solutions',
seoJsonLdOrganization: {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
const websiteSchema = jsonLd['@graph'].find(s => s['@type'] === 'WebSite');
assert(websiteSchema, 'Homepage should include WebSite schema');
assert.strictEqual(websiteSchema.name, 'Example Tech Corp');
assert.strictEqual(websiteSchema.url, 'https://example.com');
assert.strictEqual(websiteSchema.url, 'http://localhost:3000');
assert(websiteSchema.potentialAction, 'WebSite should have search action');
assert.strictEqual(websiteSchema.potentialAction['@type'], 'SearchAction');

Expand Down Expand Up @@ -158,7 +158,6 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
{ _id: global._id },
{
$set: {
seoSiteCanonicalUrl: 'https://example.com',
seoSiteName: 'Test Site',
seoJsonLdOrganization: {
name: 'Test Organization',
Expand Down Expand Up @@ -264,7 +263,6 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
{ _id: global._id },
{
$set: {
seoSiteCanonicalUrl: 'https://example.com',
seoSiteName: 'Test Site'
}
}
Expand Down Expand Up @@ -315,7 +313,6 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
{ _id: global._id },
{
$set: {
seoSiteCanonicalUrl: 'https://example.com',
seoSiteName: 'Test Site'
}
}
Expand Down Expand Up @@ -443,7 +440,6 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
{ _id: global._id },
{
$set: {
seoSiteCanonicalUrl: 'https://example.com',
seoSiteName: 'Test Site for LLMs',
seoSiteDescription: 'A test site demonstrating llms.txt',
llmsTxtSelection: 'allow'
Expand All @@ -460,7 +456,7 @@ describe('@apostrophecms/seo - Integration Tests (Actual Page Output)', function
llmsTxt.includes('A test site demonstrating llms.txt'),
'Should include site description'
);
assert(llmsTxt.includes('https://example.com'), 'Should include base URL');
assert(llmsTxt.includes('http://localhost:3000'), 'Should include base URL');
assert(
llmsTxt.includes('## AI Training Policy') ||
llmsTxt.includes('AI Training'),
Expand Down
2 changes: 0 additions & 2 deletions packages/seo/test/unit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ describe('@apostrophecms/seo', function () {

const schemas = handler.generateSchemas(data);
const articleSchema = schemas.find(s => s['@type'] === 'Article');
console.log(articleSchema);// eslint-disable-line no-console

assert(articleSchema.author, 'author should exist');
assert.strictEqual(articleSchema.author.name, 'John Doe');
});
Expand Down
Loading