SvelteKit Starter Kit
Words are nice... but code speaks louder. Dive into a fully commented project template, showcasing these techniques (and more) in action.
Sorry, no results found for "".
Similarly to what we offer with responsive images, our GraphQL API also offers a way to fetch pre-computed SEO meta tags based on the content you insert inside DatoCMS.
You can easily use this information inside your Svelte app with the help of our @datocms/svelte
package.
Here's a sample of the meta tags you can automatically generate:
To do that, first install the @datocms/svelte
package.
yarn add @datocms/svelte
Then, inside your +page.server.ts
, feed content coming from a faviconMetaTags
or _seoMetaTags
query:
const query = ` query HomeQuery { site: _site { favicon: faviconMetaTags { attributes content tag } } blog { seo: _seoMetaTags { attributes content tag } } }`;
export const load = () => { return executeQuery(query);};
Then use the <Head />
component to apply them to the page:
<script> import { Head } from '@datocms/svelte';
export let data;</script>
<Head data={[...data.page.seo, ...data.site.favicon]} />
Want to know more about SEO customization in DatoCMS? Check out this video tutorial: