| 1 | ---
|
| 2 | title: Meta Tags and SEO
|
| 3 | hidden: true
|
| 4 | ---
|
| 5 |
|
| 6 | [copy pasted from route module doc]
|
| 7 |
|
| 8 | By default, meta descriptors will render a [`<meta>` tag][meta-element] in most cases. The two exceptions are:
|
| 9 |
|
| 10 | - `{ title }` renders a `<title>` tag
|
| 11 | - `{ "script:ld+json" }` renders a `<script type="application/ld+json">` tag, and its value should be a serializable object that is stringified and injected into the tag.
|
| 12 |
|
| 13 | ```tsx
|
| 14 | export function meta() {
|
| 15 | return [
|
| 16 | {
|
| 17 | "script:ld+json": {
|
| 18 | "@context": "https://schema.org",
|
| 19 | "@type": "Organization",
|
| 20 | name: "React Router",
|
| 21 | url: "https://reactrouter.com",
|
| 22 | },
|
| 23 | },
|
| 24 | ];
|
| 25 | }
|
| 26 | ```
|
| 27 |
|
| 28 | A meta descriptor can also render a [`<link>` tag][link-element] by setting the `tagName` property to `"link"`. This is useful for `<link>` tags associated with SEO like `canonical` URLs. For asset links like stylesheets and favicons, you should use the [`links` export][links] instead.
|
| 29 |
|
| 30 | ```tsx
|
| 31 | export function meta() {
|
| 32 | return [
|
| 33 | {
|
| 34 | tagName: "link",
|
| 35 | rel: "canonical",
|
| 36 | href: "https://reactrouter.com",
|
| 37 | },
|
| 38 | ];
|
| 39 | }
|
| 40 | ```
|