erlang / erlang-org

The erlang.org website
https://www.erlang.org
Apache License 2.0
73 stars 52 forks source link

Add .html to redirects #142

Closed wojtekmach closed 6 months ago

wojtekmach commented 6 months ago

Going to https://www.erlang.org/doc/man/zlib redirects to https://www.erlang.org/doc/apps/erts/zlib however notice "zlib" is not "selected" in the sidebar:

image

only when we click it in the sidebar it is:

image

and the difference is:

This makes a big difference in apps with lots of modules like stdlib:

In the latter case, ExDoc highlights the module name and importantly scrolls sidebar down to its position.

If possible, I believe a quick fix is to add .html extension to redirects. Otherwise, we can look into support it in ExDoc somehow.

garazdawi commented 6 months ago

On netlify all URLs can be given without the .html extension, so even if we fix the redirects, google search and others can crawl to the variant without .html extension. So I think this problem needs to be solved in ex_doc.

wojtekmach commented 6 months ago

Got it, thanks, I'll look into it.

wojtekmach commented 6 months ago

If it would not break anything (and be even possible, no idea) would you be open to „un-prettify” links on Netlify, that is, non-.html urls would redirect to with .html? The benefits would be possible better SEO, instead of having both /gen_server and /gen_server.html links out there we’d standardize on the latter which would match ExDoc generated ones using autolinking feature.

josevalim commented 6 months ago

For now, I have fixed ExDoc to handle URLs without .html, there were three spots, but there are probably more. We could also setup a redirect on ExDoc side though.

Regarding better SEO, I recommend Erlang to set the --canonical flag/config. This way, Erlang can keep a history of OTP versions hosted, but Google will only redirect to the main, latest one. This will solve both the .html issue AND any versioning. Here is where we set canonical in Elixir, we set it for everything, except for nightly/main builds: https://github.com/elixir-lang/elixir/blob/f0ebedc627220fef490ea2382432332d2d250466/lib/elixir/scripts/mix_docs.exs#L6

PS: if there are any questions if all versions should point to the latest one as canonical, this seems to have been the consensus in the Elixir community. People were getting frustrating from Elixir v1.12 being the top results while 1.16 was out (and so on).

garazdawi commented 6 months ago

I've opened #143 to address some issues. I don't think I can make Netlify redirect all URLs without .html to the .html version, but I can look into it.

josevalim commented 6 months ago

@garazdawi we could also set the redirect by injecting some JS code in <head> but perhaps canonical is enough.

garazdawi commented 6 months ago

I think I'll leave it as is for now and we'll see if any issues show up due to this.

garazdawi commented 6 months ago

Closing this for now. Please let me know if you encounter any more issues.