-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up redirects based on 404 data & filter sitemap #1976
Conversation
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
const { lang } = Astro.params; | ||
--- | ||
|
||
<meta http-equiv="refresh" content={`0;url=/${lang}/tutorial/0-introduction/`} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this show up in the sitemap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent question. The answer is: yes!
https://deploy-preview-1976--astro-docs-2.netlify.app/sitemap-0.xml
We can filter sitemap URLs I believe. Let me look at that — we should probably exclude our other similar redirects too. (Probably doesn’t matter too much — these redirect pages are completely empty so are very unlikely to be indexed, but still.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, question back time: does it matter if it is in sitemap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its usually best to keep redirects out of the sitemap, but that can be tackled in a separate PR 👍
Its really not a huge deal in general, I think it's pretty common for redirects to linger in a sitemap for a while (or forever on some sites)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK — pushed a fix for the low-hanging fruit here. Our [lang]/something.astro
redirects like the one added in this PR are easy to filter out. Other dynamic redirects in the root of src/pages/
will be trickier and can be tackled later I guess (or refactored to be configured in netlify.toml
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Engaged morning brain and implemented a much better filtering set-up so now the sitemap shouldn’t include any of our redirect routes!
No objections here, once you're happy @delucis ! Just putting it on the radar that since we've discussed adding additional content in the "Tutorials" section, maybe it's time for @Jutanium and I to start discussing/sketching out a generic tutorial landing page anyway? I think this could fit in next sprint, actually! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
/** Get a preconfigured instance of the `@astrojs/sitemap` integration. */ | ||
export function sitemap(): AstroIntegration { | ||
return AstroSitemap({ | ||
filter: (page) => isValidPath(new URL(page).pathname), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
What kind of changes does this PR include?
Description
Add a Netlify redirect for an old
renderer-reference
URLAdd a route with a
<meta>
refresh redirect for/[lang]/tutorial
We may one day have an actual
/tutorial
landing page potentially, so using a.astro
route with<meta>
seemed safer than configuring a Netlify redirect we’d be more likely to forget to remove.Testing
These URLs were 404s but should now work: