Converting From Blogdown to Distill

A meta post on transferring from a blogdown to distill blog site

Distill
Author
Published

January 12, 2021

Modified

October 12, 2023

Authors Note

I have since converted this blog to a quarto blog, but am leaving this post up in case anyone finds it useful

Introduction

This metapost describes changing my personal blog from a blogdown site to a distill blog site. I will not be going over starting a site from scratch as there are already several great resources for doing this. What I will be going over is some of the challenges and some of the changes and tips I have found. If you are looking to start a site from scratch, check out these great resources:

  • The Distill for Rmarkdown page on creating a blog
  • This excellent post from Shamindra Shrotriya on setting up a blog
  • This post from the Mockup blog

This last post goes into some of the pros and cons of using distill instead of blogdown. If you want simplicity, go with distill without much customization. If you want the ability for a lot of customization and don’t mind being frustrated with Hugo, go with blogdown.

Challenges

The good thing about switching from blogdown to distill was I had very few challenges! The distill documentation, combined with the two posts I listed, helped me with most of my troubles. The only issue I ran into was distill contains a function called import_post(), which according to the docs, only needs a published URL to work. I could never solve why, but I could not pull in the posts from my old blogdown site. This wasn’t a big deal as I had the original rmarkdown documents, but this could pose an issue if you didn’t.

Going Outside the Box

Code Folding

When I converted my blog on 12/30/2020, code folding was not included as an option by default in distill. At that time, an excellent package called Codefolder added the functionality. Since going live with the blog, code folding has been added to distill.1 Code folding is available for either the whole document or individual code sections. The default caption is “Show Code”, but instead of typing code_folding=TRUE, you can provide a string to change the caption.

# Some awesome code 
# That does awesome things

Customizing the Home Page

By default, a distill blog’s home page will be the blog index page. I chose to edit my home page to be a landing page for myself and then have the blog index as a separate page. When creating a new blog, this is the default YAML header for your index page.

---
title: "New Site"
site: distill::distill_website
listing: posts
---

The critical piece here is the line site: distill::distill_website. This line is what is needed to render the website. For my home page, I decided to use the package Postcard, which is used to generate simple landing pages. I won’t go into every step as there is already a great post by Alison Hill on how to do that. However, I will point out the most crucial part of the new index page the YAML header needs to contain these two lines.

output:
  postcards::trestles
site: distill::distill_website

Final Thoughts

I have enjoyed the simplicity of Distill. While not nearly as customizable as blogdown, getting a blog site up and running in under an hour is pretty lovely. I hope to keep exploring what Distill has to offer and keep posting my updates!

Footnotes

  1. Note that as of publishing, code folding is only available in the development version of distill↩︎

Reuse

Citation

BibTeX citation:
@online{belanger2021,
  author = {Belanger, Kyle},
  title = {Converting {From} {Blogdown} to {Distill}},
  date = {2021-01-12},
  langid = {en}
}
For attribution, please cite this work as:
Belanger, Kyle. 2021. “Converting From Blogdown to Distill.” January 12, 2021.