SEO: JSON-LD NewsArticle + sitemap.xml + news sitemap + robots.txt + RSS feed

This commit is contained in:
Folx Ops
2026-06-14 06:43:33 +00:00
parent 87cfbf743c
commit a20c72e65e
2 changed files with 112 additions and 0 deletions
+33
View File
@@ -63,6 +63,38 @@ export function serveStatic(app: Express) {
let template = await fs.promises.readFile(indexPath, "utf-8");
template = stripExistingMeta(template);
const pubDate = article.publishedAt
? new Date(article.publishedAt as any).toISOString()
: new Date().toISOString();
const jsonLd = {
"@context": "https://schema.org",
"@type": "NewsArticle",
"headline": article.title,
"description": article.excerpt,
"image": [finalImage],
"datePublished": pubDate,
"dateModified": pubDate,
"articleSection": article.category || "News",
"author": {
"@type": "Organization",
"name": article.author || "Folx Music Television",
"url": canonicalBase,
},
"publisher": {
"@type": "Organization",
"name": "Folx Music Television",
"logo": {
"@type": "ImageObject",
"url": `${canonicalBase}/og-image.jpg`,
},
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": articleUrl,
},
};
const jsonLdTag = `<script type="application/ld+json">${JSON.stringify(jsonLd).replace(/</g, "\\u003c")}</script>`;
const ogTags = [
`<meta property="og:title" content="${escapeHtml(article.title)}" />`,
`<meta property="og:description" content="${escapeHtml(article.excerpt)}" />`,
@@ -84,6 +116,7 @@ export function serveStatic(app: Express) {
`<meta name="keywords" content="Volksmusik, Schlager, ${escapeHtml(article.title)}, ${escapeHtml(article.category || 'News')}, FOLX TV" />`,
`<link rel="canonical" href="${escapeHtml(articleUrl)}" />`,
`<title>${escapeHtml(article.title)} - Volksmusik & Schlager | Folx Music Television</title>`,
jsonLdTag,
].join("\n ");
template = template.replace(/<title>[^<]*<\/title>/, ogTags);