Skip to content

Add rendering of the web into a directory #2174

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

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Jul 26, 2025

This is an experimental implementation of turning the Rust website from a dynamic website to a static website (a bunch of assets in a directory on disk).

I sketched out a simple API for rendering the individual pages/routes, and got the index and governance pages to work, including translations.

If you agree with the approach, I can continue :)

@senekor
Copy link
Contributor

senekor commented Jul 26, 2025

As long as the output is good, I won't be pedantic about the code. So, feel free to go ahead and thanks for working on this!

@Manishearth
Copy link
Member

Yeah, we've wanted this!

@Manishearth
Copy link
Member

We should start to think about what this means for the team and rust version bits, which are dynamic. Probably just regen a couple times a day and have a manual trigger. Probably via GitHub actions.

@Kobzol
Copy link
Member Author

Kobzol commented Jul 26, 2025

Yes, deploying from GH actions e.g. once per day, plus triggering the deploy when a release happens, is IMO enough.

What about the approach to land this? Are you fine with me completely ripping out Rocket and "atomically" switching to the static web? We could do that using other approaches than Heroku, I suppose.

Or do you want the static and dynamic approach to live side-by-side for some time?

@Kobzol
Copy link
Member Author

Kobzol commented Aug 1, 2025

@senekor Any thoughts about how to approach the change? Are you fine with landing a PR that completely switches the website over to a static web (that would be ofc the simplest)?

@senekor
Copy link
Contributor

senekor commented Aug 1, 2025

Yeah, I'm fine with switching over all at once.

@Manishearth
Copy link
Member

I think it should be fine as long as you can generate redirects.

cc @rust-lang/infra for the Heroku part

@Kobzol
Copy link
Member Author

Kobzol commented Aug 2, 2025

What do you mean by redirects?

@senekor
Copy link
Contributor

senekor commented Aug 2, 2025

There is some redirect logic in src/redirect.rs. I'm guessing we should reproduce that behavior by generating redirect pages. Something with:

<meta http-equiv="refresh" content="0; url={{ url }}">

@Kobzol
Copy link
Member Author

Kobzol commented Aug 4, 2025

I see. Hmm, that is a bit hacky, but as a workaround why not, I guess. Depending on the method for static deployment that we choose, we might want to use something better on the webserver layer.

@pietroalbini
Copy link
Member

I would do both the meta refresh and a <script>location.href = "{{ url }}";</script>: when I did redirects like that in the past I noticed that JS ones are way faster to execute than the meta refresh ones. We should still include the meta refresh for clients not able to execute JS though.

@Kobzol
Copy link
Member Author

Kobzol commented Aug 6, 2025

I pushed an MVP, together with GitHub Pages integration. A demo is available here: https://kobzol.github.io/www.rust-lang.org/

Some things missing/unclear:

  1. Is Pontoon still needed? It doesn't seem to be enabled on the live site.
  2. Redirects are only partially working. I can do simple HTML page redirects, and also try to replicate the logic for redirecting the pre-2018 language redirects (is that still needed?), but I don't know how to do non-HTML redirects, in particular things /pdfs/foo.pdf to /static/pdfs/foo.pdf.
  3. The JS language switcher can't deal with a non / base URL yet.

@jieyouxu
Copy link
Member

jieyouxu commented Aug 6, 2025

Is Pontoon still needed? It doesn't seem to be enabled on the live site.

Probably not? The instance is dead for a while, and no one had the bandwidth/motivation to fix it. (It's for translation.)

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

Successfully merging this pull request may close these issues.

5 participants