Skip to content

Migrate to Zola #1563

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

Merged
merged 22 commits into from
Apr 14, 2025
Merged

Migrate to Zola #1563

merged 22 commits into from
Apr 14, 2025

Conversation

senekor
Copy link
Contributor

@senekor senekor commented Apr 9, 2025

closes #1522

A preview is deployed with GitHub Actions on my fork.

A comparison of the output before & aftered (slightly doctored to make it somewhat useful): https://github.com/rust-lang/blog.rust-lang.org/compare/bd43cef553fa63a5fb7fbd311c3e9329f715f1c0..72b0efba957ed22d543406fcce8ad251008c6afc

Rendered

@senekor
Copy link
Contributor Author

senekor commented Apr 9, 2025

At this point in time, everything is in place at first glance. Both blogs render all their pages, they loook the same, the blog posts themselves look the same, the feeds are there...

However, the output in terms of HTMl files etc. is nowhere near identical to before, so it's super hard to determine if there aren't any regressions. I'll note down some notable things that I know changed:

  • Pages moved from slug.html to slug/index.html. There are also hash-preserving redirects at slug.html/index.html so permalinks aren't broken.

  • The syntax highlighting is completely changed to Zolas builtin solution. The theme is a different one, I think it looks nice, but that is obviously a prefrence. We can now easily pick one of the other available themes is desired. There's also one clear improvement of syntax highlighting: Previously, code fences without a language specifiers where highlighted as Rust code by default. That might seem resonable for a blog about Rust, but it forced people to put random other specifiers on blocks that weren't Rust code ("console", "text" etc.). Sometimes that was forgotten and the block was highlighted pretty weirdly. One example is this page where console output is sometimes highlighted as Rust code.

  • The markdown source files of the content obviously stays mostly the same, but the front matter is migrated automatically. (If there are pending PRs of posts that have the old front matter, they can fix it by running a single command: FIX_FRONT_MATTER=1 cargo test -p front_matter). There are also some slight changes to the markdown files themselves. Namely, section IDs are generated a little differently so links to other sections of the same post were manually fixed. Zola checks internal links on every build, so I'm confident about this. Another content change is that unknown language specifiers on code blocks were removed, because Zola generates a ton of annoying warnings for them. It doesn't make a difference in the output, because unknown languages aren't highlighted anyway. Those languages that were just improperly named were fixed (e.g. rust= -> rust, shell -> sh)

  • I'm a little concerned about the feeds. They changed a little bit, for example the releases.json now has foobar/ as the url instead of foobar.html. I'm also not 100% about the atom feed, since I don't use it. Those feeds are probably read by machines, which might be fussy about small differences like that. I don't know all the programs that might be reading these, so it's hard to test if this isn't breaking anything.

  • A sitemap and a robots.txt have been added automatically by Zola. I suppose there is no reason to remove them.(?)

@senekor
Copy link
Contributor Author

senekor commented Apr 9, 2025

Also, it should be noted that we currently have to use a fork of Zola. The maintainer doesn't seem very responsive at the moment, but hopefully the features we need can be upstreamed in a reasonable time frame.

@senekor
Copy link
Contributor Author

senekor commented Apr 9, 2025

Here is a doctored version of the diff between the output before and after. I removed the generated redirects, those are just noise. And I renamed files in one version so the diff relibly detect them as a single modified file (as opposed to one file being deleted and a slightly different one being created from scratch).

https://github.com/rust-lang/blog.rust-lang.org/compare/bd43cef553fa63a5fb7fbd311c3e9329f715f1c0..72b0efba957ed22d543406fcce8ad251008c6afc

@senekor senekor force-pushed the senekor/zola branch 2 times, most recently from 9e93870 to 91a8d48 Compare April 9, 2025 21:41
@senekor senekor marked this pull request as ready for review April 9, 2025 22:44
@senekor
Copy link
Contributor Author

senekor commented Apr 9, 2025

Spent quite a while combing through the output diff, I can't find anything that's wrong anymore.

IMO the riskiest parts of this PR are:

  • The atom feed is changed, especially including the IDs of each entry. What's the worst case here? People's RSS readers will spuriously notify them of 10 new blog posts? That would seem acceptable to me.
  • The releases.json feed changed. Which tools rely on the url key of that feed to remain stable?
  • We have to use a fork of Zola for the time being. The patches aren't big though.

@Manishearth sorry, it's a big one... 😅

@senekor senekor requested a review from Manishearth April 9, 2025 22:44
senekor added 2 commits April 12, 2025 00:08
The front matter is defined in such a way that it can parse both the
previous and the new format that's required for Zola.

An automatic migration can be triggered with:

FIX_FRONT_MATTER=1 cargo test -p front_matter

which will be done in a separate commit.
senekor added 18 commits April 12, 2025 00:11
This patch was generated by running:

FIX_FRONT_MATTER=1 cargo test -p front_matter
The custom site generator used comrak for markdown to html translation
while Zola uses pulldown-cmark. One of them uses a <section> while the
other uses <footer class="footnotes"> to render the footnotes. So a few
CSS tweaks were needed to apply the correct styles to the footnotes.
The custom anchor link template is needed to remove the default content.
It is also a convenient way to make the classes in our existing CSS
match the new anchor links.
These tweaks make the output more similar to the one of the custom SSG,
allowing easier diffing between the two setups.
@Manishearth
Copy link
Member

Landable as is, the issue with code blocks can be figured out later.

Thanks for doing this!!

senekor added 2 commits April 14, 2025 20:48
This blog post was merged while the Zola migration PR was being
reviewed, so its front matter is migrated here in a separate commit.
@senekor
Copy link
Contributor Author

senekor commented Apr 14, 2025

Great! Only added another commit migrating the front matter of a post that was merged recently.

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

fire at will

@senekor senekor merged commit 8f2cf06 into master Apr 14, 2025
4 checks passed
@senekor senekor deleted the senekor/zola branch April 14, 2025 19:00
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.

Migrate to Zola
2 participants