feat(seo): enhance multilingual support and SEO handling
All checks were successful
Deploy to production / deploy (push) Successful in 2m46s

- Added support for multiple languages in the frontend, including English, Spanish, and Cebuano, improving accessibility for a broader audience.
- Implemented hreflang links for better SEO performance, ensuring search engines can correctly index language-specific content.
- Updated SEO metadata handling to utilize internationalization keys, enhancing the clarity and relevance of page titles and descriptions.
- Refactored SEO utility functions to streamline the management of OpenGraph and hreflang attributes, improving maintainability and performance.
This commit is contained in:
Torsten Schulz (local)
2026-04-07 15:43:16 +02:00
parent ebb2283646
commit c5b8860605
13 changed files with 542 additions and 98 deletions

View File

@@ -46,7 +46,16 @@
import { getBlog, listPosts, createPost } from '@/api/blogApi.js';
import DOMPurify from 'dompurify';
import RichTextEditor from './components/RichTextEditor.vue';
import { applySeo, buildAbsoluteUrl, createBlogSlug, stripHtml, truncateText } from '@/utils/seo.js';
import {
applySeo,
buildAbsoluteUrl,
createBlogSlug,
stripHtml,
truncateText,
seoSchemaLang,
seoOgLocale,
seoHtmlLang,
} from '@/utils/seo.js';
export default {
name: 'BlogView',
props: { id: String, slug: String },
@@ -92,13 +101,20 @@ export default {
const summarySource = this.blog.description || plainTextPosts || this.$t('blog.view.fallbackDescription');
const description = truncateText(summarySource, 160);
const canonicalPath = this.canonicalBlogPath();
const uiLang = this.$store.state.language;
const pageTitle = this.$te('seo.blogPost.pageTitle')
? this.$t('seo.blogPost.pageTitle', { title: this.blog.title })
: `${this.blog.title} | YourPart`;
applySeo({
title: `${this.blog.title} | Blog auf YourPart`,
title: pageTitle,
description,
canonicalPath,
keywords: `Blog, ${this.blog.title}, ${this.blog.owner?.username || 'YourPart'}, Community`,
type: 'article',
locale: seoOgLocale(uiLang),
lang: seoHtmlLang(uiLang),
includeHreflangAlternates: true,
jsonLd: [
{
'@context': 'https://schema.org',
@@ -106,7 +122,7 @@ export default {
name: this.blog.title,
description,
url: buildAbsoluteUrl(canonicalPath),
inLanguage: 'de',
inLanguage: seoSchemaLang(uiLang),
author: this.blog.owner?.username
? {
'@type': 'Person',
@@ -150,6 +166,9 @@ export default {
description: this.$t('blog.view.notFoundDescription'),
canonicalPath: '/blogs',
robots: 'noindex, nofollow',
locale: seoOgLocale(this.$store.state.language),
lang: seoHtmlLang(this.$store.state.language),
includeHreflangAlternates: true,
});
} finally { this.loading = false; }
},