Refactor SEO meta tag generation to ensure proper URL formatting across homepage and configurator, enhancing SEO accuracy and consistency.
This commit is contained in:
@@ -212,6 +212,9 @@ const generateHomepageMetaTags = (baseUrl, config) => {
|
|||||||
const keywords = config.keywords;
|
const keywords = config.keywords;
|
||||||
const imageUrl = `${baseUrl}${config.images.logo}`;
|
const imageUrl = `${baseUrl}${config.images.logo}`;
|
||||||
|
|
||||||
|
// Ensure URLs are properly formatted
|
||||||
|
const canonicalUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<!-- SEO Meta Tags -->
|
<!-- SEO Meta Tags -->
|
||||||
<meta name="description" content="${description}">
|
<meta name="description" content="${description}">
|
||||||
@@ -221,7 +224,7 @@ const generateHomepageMetaTags = (baseUrl, config) => {
|
|||||||
<meta property="og:title" content="${config.descriptions.short}">
|
<meta property="og:title" content="${config.descriptions.short}">
|
||||||
<meta property="og:description" content="${description}">
|
<meta property="og:description" content="${description}">
|
||||||
<meta property="og:image" content="${imageUrl}">
|
<meta property="og:image" content="${imageUrl}">
|
||||||
<meta property="og:url" content="${baseUrl}">
|
<meta property="og:url" content="${canonicalUrl}">
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:site_name" content="${config.siteName}">
|
<meta property="og:site_name" content="${config.siteName}">
|
||||||
|
|
||||||
@@ -233,39 +236,39 @@ const generateHomepageMetaTags = (baseUrl, config) => {
|
|||||||
|
|
||||||
<!-- Additional Meta Tags -->
|
<!-- Additional Meta Tags -->
|
||||||
<meta name="robots" content="index, follow">
|
<meta name="robots" content="index, follow">
|
||||||
<link rel="canonical" href="${baseUrl}">
|
<link rel="canonical" href="${canonicalUrl}">
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateHomepageJsonLd = (baseUrl, config, categories = []) => {
|
const generateHomepageJsonLd = (baseUrl, config, categories = []) => {
|
||||||
|
// Ensure URLs are properly formatted
|
||||||
|
const canonicalUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
||||||
|
const logoUrl = `${canonicalUrl}${config.images.logo}`;
|
||||||
|
|
||||||
const websiteJsonLd = {
|
const websiteJsonLd = {
|
||||||
"@context": "https://schema.org/",
|
"@context": "https://schema.org/",
|
||||||
"@type": "WebSite",
|
"@type": "WebSite",
|
||||||
name: config.brandName,
|
name: config.brandName,
|
||||||
url: baseUrl,
|
url: canonicalUrl,
|
||||||
description: config.descriptions.long,
|
description: config.descriptions.long,
|
||||||
publisher: {
|
publisher: {
|
||||||
"@type": "Organization",
|
"@type": "Organization",
|
||||||
name: config.brandName,
|
name: config.brandName,
|
||||||
url: baseUrl,
|
url: canonicalUrl,
|
||||||
logo: {
|
logo: {
|
||||||
"@type": "ImageObject",
|
"@type": "ImageObject",
|
||||||
url: `${baseUrl}${config.images.logo}`,
|
url: logoUrl,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
potentialAction: {
|
potentialAction: {
|
||||||
"@type": "SearchAction",
|
"@type": "SearchAction",
|
||||||
target: {
|
target: `${canonicalUrl}/search?q={search_term_string}`,
|
||||||
"@type": "EntryPoint",
|
|
||||||
urlTemplate: `${baseUrl}/search?q={search_term_string}`,
|
|
||||||
},
|
|
||||||
"query-input": "required name=search_term_string",
|
"query-input": "required name=search_term_string",
|
||||||
},
|
},
|
||||||
mainEntity: {
|
mainEntity: {
|
||||||
"@type": "WebPage",
|
"@type": "WebPage",
|
||||||
name: "Sitemap",
|
name: "Sitemap",
|
||||||
url: `${baseUrl}/sitemap`,
|
url: `${canonicalUrl}/sitemap`,
|
||||||
description: "Vollständige Sitemap mit allen Kategorien und Seiten",
|
description: "Vollständige Sitemap mit allen Kategorien und Seiten",
|
||||||
},
|
},
|
||||||
sameAs: [
|
sameAs: [
|
||||||
@@ -280,9 +283,9 @@ const generateHomepageJsonLd = (baseUrl, config, categories = []) => {
|
|||||||
"name": config.brandName,
|
"name": config.brandName,
|
||||||
"alternateName": config.siteName,
|
"alternateName": config.siteName,
|
||||||
"description": config.descriptions.long,
|
"description": config.descriptions.long,
|
||||||
"url": baseUrl,
|
"url": canonicalUrl,
|
||||||
"logo": `${baseUrl}${config.images.logo}`,
|
"logo": logoUrl,
|
||||||
"image": `${baseUrl}${config.images.logo}`,
|
"image": logoUrl,
|
||||||
"telephone": "015208491860",
|
"telephone": "015208491860",
|
||||||
"email": "service@growheads.de",
|
"email": "service@growheads.de",
|
||||||
"address": {
|
"address": {
|
||||||
@@ -299,17 +302,16 @@ const generateHomepageJsonLd = (baseUrl, config, categories = []) => {
|
|||||||
"longitude": "13.727215"
|
"longitude": "13.727215"
|
||||||
},
|
},
|
||||||
"openingHours": [
|
"openingHours": [
|
||||||
"Mo-Fr 10:00-20:00",
|
"Mo-Fr 10:00:00-20:00:00",
|
||||||
"Sa 11:00-19:00"
|
"Sa 11:00:00-19:00:00"
|
||||||
],
|
],
|
||||||
"paymentAccepted": "Cash, Credit Card, PayPal, Bank Transfer",
|
"paymentAccepted": "Cash, Credit Card, PayPal, Bank Transfer",
|
||||||
"currenciesAccepted": "EUR",
|
"currenciesAccepted": "EUR",
|
||||||
"priceRange": "€€",
|
"priceRange": "€€",
|
||||||
"serviceArea": {
|
"areaServed": {
|
||||||
"@type": "Country",
|
"@type": "Country",
|
||||||
"name": "Germany"
|
"name": "Germany"
|
||||||
},
|
},
|
||||||
"areaServed": "DE",
|
|
||||||
"contactPoint": [
|
"contactPoint": [
|
||||||
{
|
{
|
||||||
"@type": "ContactPoint",
|
"@type": "ContactPoint",
|
||||||
@@ -319,8 +321,8 @@ const generateHomepageJsonLd = (baseUrl, config, categories = []) => {
|
|||||||
"hoursAvailable": {
|
"hoursAvailable": {
|
||||||
"@type": "OpeningHoursSpecification",
|
"@type": "OpeningHoursSpecification",
|
||||||
"dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
|
"dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
|
||||||
"opens": "10:00",
|
"opens": "10:00:00",
|
||||||
"closes": "20:00"
|
"closes": "20:00:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -400,7 +402,7 @@ const generateHomepageJsonLd = (baseUrl, config, categories = []) => {
|
|||||||
"item": {
|
"item": {
|
||||||
"@type": "Thing",
|
"@type": "Thing",
|
||||||
"name": category.name,
|
"name": category.name,
|
||||||
"url": `${baseUrl}/Kategorie/${category.seoName}`
|
"url": `${canonicalUrl}/Kategorie/${category.seoName}`
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
@@ -532,7 +534,10 @@ const generateXmlSitemap = (allCategories = [], allProducts = [], baseUrl) => {
|
|||||||
const generateKonfiguratorMetaTags = (baseUrl, config) => {
|
const generateKonfiguratorMetaTags = (baseUrl, config) => {
|
||||||
const description = "Unser interaktiver Growbox Konfigurator hilft dir dabei, das perfekte Indoor Growing Setup zusammenzustellen. Wähle aus verschiedenen Growbox-Größen, Beleuchtung, Belüftung und Extras. Bundle-Rabatte bis 36%!";
|
const description = "Unser interaktiver Growbox Konfigurator hilft dir dabei, das perfekte Indoor Growing Setup zusammenzustellen. Wähle aus verschiedenen Growbox-Größen, Beleuchtung, Belüftung und Extras. Bundle-Rabatte bis 36%!";
|
||||||
const keywords = "Growbox Konfigurator, Indoor Growing, Growzelt, Beleuchtung, Belüftung, Growbox Setup, Indoor Garden";
|
const keywords = "Growbox Konfigurator, Indoor Growing, Growzelt, Beleuchtung, Belüftung, Growbox Setup, Indoor Garden";
|
||||||
const imageUrl = `${baseUrl}${config.images.placeholder}`; // Placeholder image
|
|
||||||
|
// Ensure URLs are properly formatted
|
||||||
|
const canonicalUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
||||||
|
const imageUrl = `${canonicalUrl}${config.images.placeholder}`; // Placeholder image
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<!-- SEO Meta Tags -->
|
<!-- SEO Meta Tags -->
|
||||||
@@ -543,7 +548,7 @@ const generateKonfiguratorMetaTags = (baseUrl, config) => {
|
|||||||
<meta property="og:title" content="Growbox Konfigurator - Stelle dein perfektes Indoor Grow Setup zusammen">
|
<meta property="og:title" content="Growbox Konfigurator - Stelle dein perfektes Indoor Grow Setup zusammen">
|
||||||
<meta property="og:description" content="${description}">
|
<meta property="og:description" content="${description}">
|
||||||
<meta property="og:image" content="${imageUrl}">
|
<meta property="og:image" content="${imageUrl}">
|
||||||
<meta property="og:url" content="${baseUrl}/Konfigurator">
|
<meta property="og:url" content="${canonicalUrl}/Konfigurator">
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:site_name" content="${config.siteName}">
|
<meta property="og:site_name" content="${config.siteName}">
|
||||||
|
|
||||||
@@ -555,15 +560,17 @@ const generateKonfiguratorMetaTags = (baseUrl, config) => {
|
|||||||
|
|
||||||
<!-- Additional Meta Tags -->
|
<!-- Additional Meta Tags -->
|
||||||
<meta name="robots" content="index, follow">
|
<meta name="robots" content="index, follow">
|
||||||
<link rel="canonical" href="${baseUrl}/Konfigurator">
|
<link rel="canonical" href="${canonicalUrl}/Konfigurator">
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateRobotsTxt = (baseUrl) => {
|
const generateRobotsTxt = (baseUrl) => {
|
||||||
|
// Ensure URLs are properly formatted
|
||||||
|
const canonicalUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
||||||
|
|
||||||
const robotsTxt = `User-agent: *
|
const robotsTxt = `User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
Sitemap: ${baseUrl}/sitemap.xml
|
Sitemap: ${canonicalUrl}/sitemap.xml
|
||||||
Crawl-delay: 0
|
Crawl-delay: 0
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user