Skip to content
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

site: quicker redirects to appease the SEO deities #9116

Open
wants to merge 6 commits into
base: svelte-4
Choose a base branch
from

Conversation

gtm-nayan
Copy link
Contributor

pls work

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2023

⚠️ No Changeset found

Latest commit: 0f9b706

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -0,0 +1,2 @@
export const prerender = true;
export { GET } from '../docs/+server.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should make docs.html return anything. It returns "500 | not found" right now, which is really weird, but we should just fix that to return 404

Copy link
Contributor Author

@gtm-nayan gtm-nayan Aug 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to get it to output the same prerendered files as it did before, not sure why it's a 500/404 currently because there is a docs.html in the prerendered output. Some manifest thing maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably sveltejs/kit#10565 will fix the 500/404 thing

https://svelte.dev/docs.html doesn't currently return anything, but would with this PR, so this isn't really making it equivalent to what it was before

@dummdidumm
Copy link
Member

What's the status on this? Good to merge?

@dummdidumm
Copy link
Member

What's the argument for changing this? Is this really quicker for SEO reasons? Right now we're loading the page and its JS and then redirecting which is quick. With this we're loading one page and then doing a full page redirect somewhere else. Not sure which is really faster.

@gtm-nayan
Copy link
Contributor Author

gtm-nayan commented Oct 19, 2023

Client side redirects that only happen after a large amount of resoursces are downloaded (hydration, module preloads yada yada) so crawler wasn't picking up redirects from old links, or at least that was the hypothesis. I don't have a link handy now but I read somewhere in Google's docs that they do process some amount of client side redirects.

The payload for the first request is a lot smaller with the PR because for example, it doesn't have the nav bar data embedded into the HTML. The cumulative time for both requests should be equivalent for human visitors with the PR but the first one needs to be fast enough for the bots to even consider the redirect.

@dummdidumm
Copy link
Member

dummdidumm commented Oct 19, 2023

Makes sense, thanks! Anything you'd like to change in this PR still (specifically your conversation with Ben above) or are we basically good to merge?

@benmccann
Copy link
Member

I was concerned that this will make /docs.html start returning something, which I don't think we want to do: #9116 (comment). Is that something we could avoid?

@gtm-nayan
Copy link
Contributor Author

I was concerned that this will make /docs.html start returning something

Does that cause any problems other than it not being exactly equivalent to what it was before? We'd need to implement a way to tell SK "treat this endpoint result as a page response" to get the prerendering behaviour like before.

@dummdidumm
Copy link
Member

What exactly do you mean by "return something"? Visually they're the same between this PR and main

@gtm-nayan
Copy link
Contributor Author

https://svelte.dev/docs.html is a 404 now (well 500, just needs a Kit bump hopefully) which would change with this PR

@benmccann
Copy link
Member

I wonder if the better approach might be to replace the client-side redirects with server-side redirects. There are some without # and those could certainly be done on the server-side. For the ones with # I wonder if we could send to it something like page?focus=anchor and then put something in layout.svelte which focuses the given anchor and updates the URL to page#anchor

@dummdidumm
Copy link
Member

That will still require logic on the client, which as it seems will sometimes be too slow for redirects to be noticed

@benmccann benmccann added the site label Oct 19, 2023
@benmccann
Copy link
Member

The client-side logic would only be needed by users in that case, so it would be fine if it's too slow for Google to notice. For Google the only thing we need is to get it to the correct page. Google doesn't need the anchor part of the link as it will index and rank the whole page and not just that section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants