-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add robots.txt and sitemap.xml (#456)
Co-authored-by: Kent C. Dodds <[email protected]>
- Loading branch information
1 parent
a0cfdb6
commit 45f6322
Showing
19 changed files
with
134 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { generateRobotsTxt } from '@nasa-gcn/remix-seo' | ||
import { type DataFunctionArgs } from '@remix-run/node' | ||
import { getDomainUrl } from '#app/utils/misc.tsx' | ||
|
||
export function loader({ request }: DataFunctionArgs) { | ||
return generateRobotsTxt([ | ||
{ type: 'sitemap', value: `${getDomainUrl(request)}/sitemap.xml` }, | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { generateSitemap } from '@nasa-gcn/remix-seo' | ||
// @ts-expect-error - this does work, though it's not exactly a public API | ||
import { routes } from '@remix-run/dev/server-build' | ||
import { type DataFunctionArgs } from '@remix-run/node' | ||
import { getDomainUrl } from '#app/utils/misc.tsx' | ||
|
||
export function loader({ request }: DataFunctionArgs) { | ||
return generateSitemap(request, routes, { | ||
siteUrl: getDomainUrl(request), | ||
headers: { | ||
'Cache-Control': `public, max-age=${60 * 5}`, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SEO | ||
|
||
Remix has built-in support for setting up `meta` tags on a per-route basis which | ||
you can read about | ||
[in the Remix Metadata docs](https://remix.run/docs/en/main/route/meta). | ||
|
||
The Epic Stack also has built-in support for `/robots.txt` and `/sitemap.xml` | ||
via [resource routes](https://remix.run/docs/en/main/guides/resource-routes) | ||
using [`@nasa-gcn/remix-seo`](https://github.com/nasa-gcn/remix-seo). By | ||
default, all routes are included in the `sitemap.xml` file, but you can | ||
configure which routes are included using the `handle` export in the route. Only | ||
public-facing pages should be included in the `sitemap.xml` file. | ||
|
||
Here are two quick examples of how to customize the sitemap on a per-route basis | ||
from the `@nasa-gcn/remix-seo` docs: | ||
|
||
```tsx | ||
// routes/blog/$blogslug.tsx | ||
|
||
export const handle: SEOHandle = { | ||
getSitemapEntries: async request => { | ||
const blogs = await db.blog.findMany() | ||
return blogs.map(blog => { | ||
return { route: `/blog/${blog.slug}`, priority: 0.7 } | ||
}) | ||
}, | ||
} | ||
``` | ||
|
||
```tsx | ||
// in your routes/url-that-doesnt-need-sitemap | ||
import { SEOHandle } from '@nasa-gcn/remix-seo' | ||
|
||
export let loader: LoaderFunction = ({ request }) => { | ||
/**/ | ||
} | ||
|
||
export const handle: SEOHandle = { | ||
getSitemapEntries: () => null, | ||
} | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.