Skip to content

fix: add missing SEO meta tags to metadata.svelte and news/[slug]#2946

Open
10-trix wants to merge 1 commit intoOWASP:masterfrom
10-trix:fix/navbar-seo-ally
Open

fix: add missing SEO meta tags to metadata.svelte and news/[slug]#2946
10-trix wants to merge 1 commit intoOWASP:masterfrom
10-trix:fix/navbar-seo-ally

Conversation

@10-trix
Copy link
Copy Markdown
Contributor

@10-trix 10-trix commented May 8, 2026

Description

Fixes missing SEO meta tags on two pages:

  1. src/lib/components/metadata.svelte — added og:title, og:description,
    twitter:title, and twitter:description which were absent from the global
    metadata component.

  2. src/routes/news/[slug]/+page.svelte — replaced the minimal <svelte:head>
    block (which only had a broken canonical pointing to /news) with a full set
    of SEO meta tags using the blogpost's title, path, and markdown content.

Resolves: #2194

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: [e.g. GitHub CoPilot, ChatGPT, JetBrains Junie etc.]
    • LLMs and versions: [e.g. GPT-4.1, Claude Haiku 4.5, Gemini 2.5 Pro etc.]
    • Prompts: [Summarize the key prompts or instructions given to the AI tools]

Affirmation

@Adarshkumar0509
Copy link
Copy Markdown
Contributor

see i have a doubt twitter:title and twitter:description appear twice in the HTML once from the global metadata.svelte and once from the article page. Duplicate meta tags cause unpredictable behavior in search engines and social platforms?

@10-trix
Copy link
Copy Markdown
Contributor Author

10-trix commented May 8, 2026

@Adarshkumar0509 Thankyou for asking.As i knew that SvelteKit automatically deduplicates the head tags, so i thought it will not be a problem for Search Engines practicaly but you have stated a correct point it might create a Unexpected Behaviour for the Social media platforms as they rendered by the Server Side.
I will reomove the title/description from metadata.svelte and keep only true Global Tags there.
Thankyou!

@Adarshkumar0509
Copy link
Copy Markdown
Contributor

overall i think its fine i think @ANNI160 , @immortal71 and @muhammad7865 will take a look.

@ANNI160
Copy link
Copy Markdown
Contributor

ANNI160 commented May 8, 2026

Great catch, @Adarshkumar0509 ! And perfect response, @10-trix. You are right that SvelteKit tries to deduplicate svelte:head elements, but social media scrapers (like Twitter and LinkedIn bots) can be notoriously picky if they see competing tags in the raw SSR HTML.

Keeping the dynamic title/description tags strictly on the individual page level and leaving only the static, site-wide tags in metadata.svelte is definitely the safest architecture.

Go ahead and push that update, @10-trix. Once it is up, I will pull your branch locally, inspect the compiled DOM, and give it a final QA check before we mark it ready for Johan. Great teamwork, guys!

Copy link
Copy Markdown
Collaborator

@sydseter sydseter left a comment

Choose a reason for hiding this comment

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

@10-trix Thank you 🙏 for your time!

@sydseter sydseter marked this pull request as ready for review May 9, 2026 00:50
@sydseter sydseter requested a review from cw-owasp as a code owner May 9, 2026 00:50
Copilot AI review requested due to automatic review settings May 9, 2026 00:50
@sydseter sydseter requested a review from rewtd as a code owner May 9, 2026 00:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve SEO/social sharing metadata by expanding the global metadata component and adding a complete set of per-article meta tags for individual news posts (/news/[slug]), addressing missing Open Graph and Twitter tags.

Changes:

  • Added og:title, og:description, twitter:title, and twitter:description to the global Metadata component.
  • Replaced the minimal/broken <svelte:head> in news/[slug] with canonical URL, title, description, and OG/Twitter tags derived from the blog post.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
cornucopia.owasp.org/src/routes/news/[slug]/+page.svelte Adds full SEO meta tag set for individual news posts, including canonical URL and social preview metadata.
cornucopia.owasp.org/src/lib/components/metadata.svelte Extends global metadata with title/description fields for Open Graph and Twitter.

Comment on lines +20 to +25
name="description"
content={blogpost.markdown
?.replace(/[#*_>`]/g, "")
.replace(/\n+/g, " ")
.trim()
.slice(0, 160)}
Comment on lines +36 to +41
property="og:description"
content={blogpost.markdown
?.replace(/[#*_>`]/g, "")
.replace(/\n+/g, " ")
.trim()
.slice(0, 160)}
Comment on lines +49 to +54
name="twitter:description"
content={blogpost.markdown
?.replace(/[#*_>`]/g, "")
.replace(/\n+/g, " ")
.trim()
.slice(0, 160)}
Comment on lines +28 to +56
<!-- Facebook Meta Tags -->
<meta
property="og:url"
content="https://cornucopia.owasp.org/news/{blogpost.path}"
/>
<meta property="og:type" content="article" />
<meta property="og:title" content="{blogpost.title} | OWASP Cornucopia" />
<meta
property="og:description"
content={blogpost.markdown
?.replace(/[#*_>`]/g, "")
.replace(/\n+/g, " ")
.trim()
.slice(0, 160)}
/>
<meta property="og:image" content="/images/opengraph.png" />

<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{blogpost.title} | OWASP Cornucopia" />
<meta
name="twitter:description"
content={blogpost.markdown
?.replace(/[#*_>`]/g, "")
.replace(/\n+/g, " ")
.trim()
.slice(0, 160)}
/>
<meta name="twitter:image" content="/images/opengraph.png" />
Comment on lines +3 to +20
<meta property="og:url" content="https://cornucopia.owasp.org/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="OWASP Cornucopia" />
<meta
property="og:description"
content="A threat modelling card game to help development teams identify security requirements."
/>
<meta property="og:image" content="/images/opengraph.png" />

<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="cornucopia.owasp.org">
<meta property="twitter:url" content="https://cornucopia.owasp.org/">
<meta name="twitter:image" content="/images/opengraph.png">
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="cornucopia.owasp.org" />
<meta property="twitter:url" content="https://cornucopia.owasp.org/" />
<meta name="twitter:title" content="OWASP Cornucopia" />
<meta
name="twitter:description"
content="A threat modelling card game to help development teams identify security requirements."
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign for cornucopia.owasp.org

5 participants