Working with and customizing SEO Fields
Play video »
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 Next app with the help of our react-datocms
package.
Here's a sample of the meta tags you can automatically generate:
To do that, install the react-datocms
package:
yarn add react-datocms
Then, inside your page, feed content coming from a faviconMetaTags
or _seoMetaTags
query directly into the renderMetaTags
function:
import { request } from "../lib/datocms";import { renderMetaTags } from "react-datocms";import Head from "next/head";
const HOMEPAGE_QUERY = ` { site: _site { favicon: faviconMetaTags { attributes content tag } } blog { seo: _seoMetaTags { attributes content tag } } }`;
export async function getStaticProps() { const data = await request({ query: HOMEPAGE_QUERY, variables: { limit: 10 } });
return { props: { data } };}
export default function Home({ data }) { return ( <div> <Head>{renderMetaTags([...data.blog.seo, ...data.site.favicon])}</Head> {/* ... */} </div> );}
Want to know more about SEO customization in DatoCMS? Check out this video tutorial: