A note from the authors: Some of the information and instructions in this book are now out of date because of changes to Hugo and the blogdown package. If you have suggestions for improving this book, please file an issue in our GitHub repository. Thanks for your patience while we work to update the book, and please stay tuned for the revised version!
— Yihui, Amber, & Alison
1.6 Other themes
In Hugo, themes control the entire appearance and functionality of your site. So, if you care a lot about the appearance of your website, you will probably spend quite a bit of time in the beginning looking for a Hugo theme that you like from the collection listed at https://themes.gohugo.io. Please note that not all themes have been tested against blogdown. If you find a certain theme does not work well with blogdown, you may report to https://github.com/rstudio/blogdown/issues, and we will try to investigate the reason, but it can be time-consuming to learn and understand how a new theme works, so we recommend that you learn more about Hugo by yourself before asking, and we also encourage users to help each other there.
After you have found a satisfactory theme, you need to figure out its GitHub username and repository name,13 then either install the theme via
blogdown::install_theme(), or just create a new site under another new directory and pass the GitHub repository name to the
theme argument of
new_site(). We recommend that you use the second approach, because Hugo themes could be very complicated and the usage of each theme can be very different and highly dependent on
config.toml. If you install a theme using
install_theme() instead of
new_site() you’ll need to manually create the
config.toml file in the root directory of your website to match the newly installed theme.14
# for example, create a new site with the anatole theme ::new_site(theme = "lxndrblz/anatole")blogdown
To save you some time, we list a few themes below that match our taste:
Multimedia content themes: If you are interested in adding multimedia content to your site (such as audio files of a podcast), the castanet theme provides an excellent framework tailored for this application. An example of a site using blogdown with the castanet theme is the R-Podcast.
Another thing to keep in mind is that the more effort you make in a complicated theme, the more difficult it is to switch to other themes in the future, because you may have customized a lot of things that are not straightforward to port to another theme. So please ask yourself seriously, “Do I like this fancy theme so much that I will definitely not change it in the next couple of years?”
If you choose to dig a rather deep hole, someday you will have no choice but keep on digging, even with tears.
— Liyun Chen15
In a workaround, if you used
install_theme()and set the
theme_exampleargument to TRUE, then you can access an example
config.tomlfile. In the
themes/directory, navigate to the file for your newly downloaded theme and find
exampleSite/config.toml. This file can be copied to your root directory (to replace the
config.tomlfile from your original theme) or used as a template to correctly write a new
config.tomlfile for your new theme.↩︎
Translated from her Chinese Weibo.↩︎