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

Make /welcome.html redirect to / #847

Closed
mgeisler opened this issue Jun 21, 2023 · 17 comments · Fixed by #1039
Closed

Make /welcome.html redirect to / #847

mgeisler opened this issue Jun 21, 2023 · 17 comments · Fixed by #1039
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mgeisler
Copy link
Collaborator

mgeisler commented Jun 21, 2023

We currently have both

  • https://google.github.io/comprehensive-rust/ (there must be an index.html page here)
  • https://google.github.io/comprehensive-rust/welcome.html

online. The latter is mostly seen when you navigate forward and then back to the start page.

We should only have one page and we should make https://google.github.io/comprehensive-rust/ the canonical page.

Fixing this might involve working on mdbook to have it generate links back to the / page instead of to /index.html.

Make sure this works for the translations as well.

@mgeisler mgeisler added bug Something isn't working good first issue Good for newcomers labels Jun 21, 2023
@AlimurtuzaCodes
Copy link

Can I work on this issue?

@mgeisler
Copy link
Collaborator Author

Can I work on this issue?

Sure, go right ahead! 😄

@AlbinXXX
Copy link

Could I work on this or is already taken by someone else? 😄

@mgeisler
Copy link
Collaborator Author

Hey @lorinaX, you could discuss with @CYBWEBALI on how to solve this. I don't know what the plan is here, but I would be curious to hear 😄

We also have another issue related to linking pages: google/mdbook-i18n-helpers#35. That would also require changing mdbook or (probably easier) write a tool which can add the necessary HTML after the book has been rendered.

@mgeisler
Copy link
Collaborator Author

Hi @CYBWEBALI and @lorinaX, please let me know if you have an idea for how to solve this 😄 It would be good to discuss it before either of you invest a lot of time into it.

@AlbinXXX
Copy link

well since the other guy didn't grab this issue, I'll go ahead and work on it right now I have a few ideas on how I can do this, I will make sure to update you after I have finished a few ideas, shouldn't take me too long!

@Tnation888

This comment was marked as off-topic.

@AlbinXXX
Copy link

Can you give me some exact steps for me to replicate this, I did some changes and I think it should be fine now.

@Tnation888

This comment was marked as off-topic.

@AlbinXXX
Copy link

AlbinXXX commented Jun 25, 2023

When we go to (comprehensive-rust/index.html). This should correspond to the canonical URL https://google.github.io/comprehensive-rust/ and when we navigate through the book and we navigate back to the start page the url should be https://google.github.io/comprehensive-rust/ and not https://google.github.io/comprehensive-rust/welcome.html.

This is to my understanding and I want to make sure I don't miss any edge case or have misunderstood the problem in any way before making a PR that is why I asked for the exact steps to replicate the problem, to fix this issue was pretty simple you just need to add the following to book.toml:
[output.html.redirects]
"/index.html" = "/"

and to make sure we have a conical-url in the [output.excerciser]
canonical-url = "http://localhost:8000" (example of my cononical-url)

(Update) unless you can run a small server I don't think there would be way to redirect this since you are hosting on github pages, my local version works with tokio and warp.

@Tnation888

This comment was marked as off-topic.

@AlimurtuzaCodes
Copy link

AlimurtuzaCodes commented Jun 26, 2023

lorinaX

I think when you set

[output.html.redirects]
"/index.html" = "/"

After putting this in book.toml file
image

As per docs of mdbook there is no such options,
canonical-url = "http://localhost:8000"

@mgeisler
Copy link
Collaborator Author

So I'm in the book already idk shit what's the name of the book I'm go get me one

Hi @Tnation888, it's great if you want to help out, but I don't understand your comment here?

@mgeisler
Copy link
Collaborator Author

I think when you set

"/index.html" = "/"

It continuously re-renders the page.

Yeah, good point! Right now there are 3 valid URLs for the same page:

Perhaps we could start by renaming welcome.md to index.md? That would reduce the number of URLs by one.

@AlimurtuzaCodes
Copy link

I think when you set

"/index.html" = "/"

It continuously re-renders the page.

Yeah, good point! Right now there are 3 valid URLs for the same page:

Perhaps we could start by renaming welcome.md to index.md? That would reduce the number of URLs by one.

I can try this.

mgeisler added a commit that referenced this issue Jul 28, 2023
When building the book, mdBook will always generate an `index.html`
page for first page of the book. This meant that we had the same
content available under two different names:

- `welcome.html`: this is what the TOC would link to, and
- `index.html` or simply `/`: this is what search engines link to

Renaming the page and setting up a redirect should fix this confusion.
We still don’t have a good way of avoiding links to the `index.html`
page, but this should fix the first half of the problem.

I tested this for translations as well by building the output in a
subdirectory and serving the parent directory.

Part of #847.
mgeisler added a commit that referenced this issue Jul 28, 2023
When building the book, mdBook will always generate an `index.html`
page for first page of the book. This meant that we had the same
content available under two different names:

- `welcome.html`: this is what the TOC would link to, and
- `index.html` or simply `/`: this is what search engines link to

Renaming the page and setting up a redirect should fix this confusion.
We still don’t have a good way of avoiding links to the `index.html`
page, but this should fix the first half of the problem.

I tested this for translations as well by building the output in a
subdirectory and serving the parent directory.

Part of #847.
@mgeisler
Copy link
Collaborator Author

mgeisler commented Aug 2, 2023

I renamed welcome.md to index.md in #1039. It would still be nice if /index.html URLs would instead become / (for all languages), but that's probably something we need to fix in upstream mdbook.

@mgeisler
Copy link
Collaborator Author

mgeisler commented Aug 2, 2023

This upstream issue would take care of removing the index.html parts from our URLs: rust-lang/mdBook#1251.

yohcop pushed a commit to yohcop/comprehensive-rust that referenced this issue Sep 12, 2023
When building the book, mdBook will always generate an `index.html`
page for first page of the book. This meant that we had the same
content available under two different names:

- `welcome.html`: this is what the TOC would link to, and
- `index.html` or simply `/`: this is what search engines link to

Renaming the page and setting up a redirect should fix this confusion.
We still don’t have a good way of avoiding links to the `index.html`
page, but this should fix the first half of the problem.

I tested this for translations as well by building the output in a
subdirectory and serving the parent directory.

Part of google#847.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants