When disaster strikes: Re-building a Quarto Blog

blogging
quarto
jupyter
Author

Christian Wittmann

Published

November 27, 2022

For the last 2 months I have been a proud writer of this blog, until yesterday disaster struck: Upon publishing of my MNIST-blog post via the usual quarto publish gh-pages, I received the following error message 😨:

fatal: 'gh-pages' is already checked out at /mnt/c/Users/chrwi/OneDrive/Dokumente/GitRepos/chrwittm.github.io/bc75ca74

The publishing was not completed, and my blog only showed a naked header, but no posts any more, essentially everything was gone 😱 (at least online)

Trying to google a quick fix did not reveal any real result. Due to lack of time, I had to (officially) stop for the day, but back in my mind, this was really nagging me…

What is needed to Re-build a Quarto Blog?

As I kept thinking about this, the error message clearly pointed to something on my local machine. Additionally, I previously posted on how to avoid disaster, so what would be the best way to re-build everything?

But let’s think through the matter: What do you actually need to re-build a Quarto blog? You only need your posts-directory and a few other files (the ones mentioned here).

This is important, so let me re-phrase this: On your GitHub repo, there are (should be) 2 versions of your blog:

  • In the main-branch, you store your source-files:
    • The Jupyter notebooks, markdown files, some pictures used within your posts
    • The configuration files: Some .yml-, .qmd- and .css-files
  • The gh-pages branch gets generated to contain the rendered versions of your posts: When you check out your _site directory, it contains a file structure similar to the posts-directory in your main-branch, but the _site directory deals in html-, xml-, and json-files.

Therefore, to re-build your site, as far as I understand it, you only need the content of your main branch, and the content of the gh-pages gets generated once you run quarto publish gh-pages.

Re-building my Quarto Blog

With the above in mind, here is what I did:

  • I moved my local copy of the blog’s repo’s main branch to my temp folder (the milder version of deleting it)
  • I re-cloned the repo (the main branch): git clone git@github.com:chrwittm/chrwittm.github.io.git
  • I re-published the blog: quarto publish gh-pages

And violà: My blog was back online. 😃

Conclusion

First of all: With these kind of seeming disasters: Sit back and relax: Is this a big deal? Well my blog was down, who cared? Probably I cared the most about it - my ego 😉.

Don’t panic: Think through a problem: What could be the root cause, from what angle can you approach the problem?

I think, the solution is actually really nice. The setup with the 2 branches has some nice redundancy built-in, and without having tried it before, the disaster recovery performed very well.

The solution also reminded me of the fast-setup approach, which Jeremy discussed in the Live-Coding session 1: You should spend time using your tools, not configuring them. Quarto, at least to me, nicely proved that point that even if something goes wrong, you can quickly recover.

Happy blogging!