From 171410e1154947c6655e89c726fca1fd4365cf71 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Tue, 5 Aug 2025 11:25:39 +0800 Subject: [PATCH] BLOG-48 SEO Improvement (#116) ### Description #### Overview This PR improves the website's SEO by: 1. Moving title and meta description tags from app.html to individual page components 2. Adding dynamic meta descriptions based on page content 3. Implementing structured data for blog posts using JSON-LD 4. Optimizing meta descriptions for better search engine visibility #### Changes - **app.html**: Removed static title and meta description tags - **HomePage.svelte**: Added descriptive title parameter to generateTitle function - **Terminal.svelte**: Dynamically generates meta description from terminal lines - **PostContentPage.svelte**: Added meta description and structured data for blog posts - **PostOverallPage.svelte**: Added descriptive meta description for blog listing page - **StructuredData.svelte**: Created new component to generate JSON-LD structured data for blog posts #### Benefits - Improved SEO through better metadata management - Enhanced search engine visibility with structured data - More accurate and dynamic meta descriptions - Better control over page-specific metadata > [!NOTE] > Since sitemap auto generating is a little more complex, it will be solved in #117 in the future. ### Package Changes _No response_ ### Screenshots _No response_ ### Reference Resolves #48 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: https://git.squidspirit.com/squid/blog/pulls/116 Co-authored-by: SquidSpirit Co-committed-by: SquidSpirit --- frontend/src/app.html | 2 -- .../src/lib/home/framework/ui/HomePage.svelte | 3 +- .../src/lib/home/framework/ui/Terminal.svelte | 3 ++ .../post/framework/ui/PostContentPage.svelte | 10 +++++++ .../post/framework/ui/PostOverallPage.svelte | 4 +++ .../post/framework/ui/StructuredData.svelte | 30 +++++++++++++++++++ 6 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 frontend/src/lib/post/framework/ui/StructuredData.svelte diff --git a/frontend/src/app.html b/frontend/src/app.html index 0146294..7dcb541 100644 --- a/frontend/src/app.html +++ b/frontend/src/app.html @@ -14,9 +14,7 @@ /> - 魚之魷魂 SquidSpirit - - {generateTitle()} + {generateTitle('程式、科技、教學、分享')} +
diff --git a/frontend/src/lib/home/framework/ui/Terminal.svelte b/frontend/src/lib/home/framework/ui/Terminal.svelte index 22d2788..8a2895d 100644 --- a/frontend/src/lib/home/framework/ui/Terminal.svelte +++ b/frontend/src/lib/home/framework/ui/Terminal.svelte @@ -52,6 +52,9 @@ } + + +
diff --git a/frontend/src/lib/post/framework/ui/PostContentPage.svelte b/frontend/src/lib/post/framework/ui/PostContentPage.svelte index 4137496..8bd038a 100644 --- a/frontend/src/lib/post/framework/ui/PostContentPage.svelte +++ b/frontend/src/lib/post/framework/ui/PostContentPage.svelte @@ -5,6 +5,7 @@ import markdownit from 'markdown-it'; import SafeHtml from '$lib/common/framework/ui/SafeHtml.svelte'; import generateTitle from '$lib/common/framework/ui/generateTitle'; + import StructuredData from '$lib/post/framework/ui/StructuredData.svelte'; const { id }: { id: number } = $props(); @@ -19,6 +20,15 @@ {generateTitle(state.data?.info.title)} + {#if state.data} + + + {/if}
{#if state.data} diff --git a/frontend/src/lib/post/framework/ui/PostOverallPage.svelte b/frontend/src/lib/post/framework/ui/PostOverallPage.svelte index b32a8bf..b41268e 100644 --- a/frontend/src/lib/post/framework/ui/PostOverallPage.svelte +++ b/frontend/src/lib/post/framework/ui/PostOverallPage.svelte @@ -12,6 +12,10 @@ {generateTitle('文章')} +

文章

diff --git a/frontend/src/lib/post/framework/ui/StructuredData.svelte b/frontend/src/lib/post/framework/ui/StructuredData.svelte new file mode 100644 index 0000000..e00e6d2 --- /dev/null +++ b/frontend/src/lib/post/framework/ui/StructuredData.svelte @@ -0,0 +1,30 @@ + + +{@html jsonLdScript}