Svelte framework
Add automatic MyOG.social images to SvelteKit pages with load data and server-rendered <svelte:head> tags.
SvelteKit recommends putting title and meta tags inside <svelte:head>. MyOG fits that pattern because the generated image URL can be derived from the canonical page URL.
Return the page URL or SEO data from a load function, then render og:image and twitter:image in the page or root layout head.
Keep SSR on for public pages. Client-side updates to head tags are too late for many social preview crawlers.
MyOG detects page content and branding automatically. The layout only controls image composition.
Return the generated image URL from server-side page data.
import type { PageServerLoad } from "./$types"
const siteURL = "https://example.com"
export const load: PageServerLoad = async ({ params }) => {
const pageURL = `${siteURL}/blog/${params.slug}`
const myogImageURL = `https://api.myog.social/og?url=${encodeURIComponent(pageURL)}&template=screenshot-right`
return { myogImageURL }
}Render the tags in <svelte:head> so crawlers receive them in HTML.
<script lang="ts">
import type { PageData } from "./$types"
export let data: PageData
</script>
<svelte:head>
<meta property="og:image" content={data.myogImageURL} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content={data.myogImageURL} />
</svelte:head>If your layout already renders an og:image from page data, switch that data source to MyOG. Avoid adding a second <svelte:head> image block that competes with the first one.
Use params in server load functions for posts, products, docs, and other dynamic routes. Build the public path from the route params, then encode the absolute URL for MyOG.
Start with the MyOG Open Graph Checker, then refresh social platform caches if needed.
Sign up for free and add generated OG images to SvelteKit pages.
Already have an account?
cdf733b534ea2f2ed964d150330b323c44837e4f