get Seo Metautility
utility
Generate a Remix meta array from one or more SEO configuration objects. Pass SEO configuration for the parent route(s) and the current route to preserve meta data for all active routes. Similar to Object.assign()
, each property is overwritten based on the object order. The exception is , which is preserved so that each route has it's own independent jsonLd meta data. Learn more about how SEO works in Hydrogen.
Anchor to getseometagetSeoMeta
Anchor to seoInputs
seoInputs
[]
required
takes an arbitrary number of configuration object parameters. Values in each object are overwritten based on the object order. `jsonLd` properties are preserved between each configuration object.
Was this section helpful?
Example code
import {getSeoMeta} from '@shopify/hydrogen';
export async function loader({context}) {
const {shop} = await context.storefront.query(`
query layout {
shop {
name
description
}
}
`);
return {
seo: {
title: shop.title,
description: shop.description,
},
};
}
export const meta = ({data, matches}) => {
// Pass one or more arguments, preserving properties from parent routes
return getSeoMeta(matches[0].data.seo, data.seo);
};