Could you help me understand how %s
is referencing the <SEO />
component’s title attribute inside the <Helmet />
component in the gatsby starter theme?
https://github.com/gatsbyjs/gatsby-starter-default/blob/master/src/components/seo.js
Line 19:
titleTemplate={`%s | ${data.site.siteMetadata.title}`}
2
Answers
The pattern
%s
is used to be replaced forstring
:$s
is inferred from the “title” prop of your component.Here is a link to the relevant source code:
https://github.com/nfl/react-helmet/blob/b79d30ff44c7ff3c175c31059076e5e549a1b402/src/HelmetUtils.js#L27