Table of Contents
hugo is difficult.
Blogdown offers the promise of an easy and quick workflow for blogging, however, that is not the case. If you’re not ready for some hard work, then you should probably stay with Wordpress or Squarespace. On the otherhand, if you want to understand the principles that underly much of webpage creation, then stick with
It’s virtually impossible to give a comprehensive scaffold of how to accomplish that and, even if you could, your time would be better spent reading Yihui Xie, Amber Thomas, Alison Presmanes Hill’s book on blogdown. So here’s 10 things you have to remember to for this transition to hugo go well:
blogdown::serve_site()to serve your site. Do not use
hugo servefrom the command line. The reason is because
blogdownknows what to do with files that have the
hugodoes not. Also, for those used to working with
.Rmdand instinctively pushing the “knit” button, don’t do that either.
You have to learn the directory structure to
hugo. Sorry, but you knew that was coming and it is not especially complex. See the documentation here.
themesfolder is where your chosen theme resides. It provides the formatting for your site. You can find a theme on github by using the tag
hugo-theme. Choose the simplest template to accomplish your objective and one that has a lot of stars or forks. Xie recommends only looking for repos that have been updated within the past year. Investigate widely, choose wisely. (I went with the default after experimenting with about 10 different themes.)
configfile in the root directory is probably where you’ll start. It is formatted either in
.json. Review the file extremely carefully so you have a knowledge of the options that can be configured.
You can find help in the usual places: StackOverflow and Github. Xie asked in the book to post help questions to StackOverflow rather than open an issue on Github. Remember to use the tag
[blogdown]when searching on StackOverflow. Also,
hugohas a community forum too.
Images just about drove me crazy. There’s lots of posts telling to put the image in the
staticdirectory. What many of those posts forget is that
staticwhen it creates the site. So my path was eternally wrong. (I’m talking about coding not salvation.) Here’s the post that finally made the point clear.
Set the global defaults. At the very least, author and markdown option should be set with
options(blogdown.ext = '.Rmd', blogdown.author = 'John Doe'). Details can be found in the blogdown book.
If you are using Rstudio, find the
Addinsmenu and use the “add post” feature.
Do not change layouts in the theme directory. Instead, copy the layouts to the
layoutfolder in the root directory and add the word “custom” in the filename.
Expanding on 9, you customize a theme by overriding theme layouts and static assets in your top-level project directories.