1.7 A recommended workflow

There are a lot of ways to start building a website and deploy it. Because of the sheer number of technologies that you need to learn to fully understand how a website works, we’d like to recommend one workflow to beginners, so that hopefully they do not need to digest the rest of this book. This is definitely not the most optimal workflow, but requires you to know the fewest technical details.

To start a new website:

  1. Carefully pick a theme at http://themes.gohugo.io, and find the link to its GitHub repository, which is of the form https://github.com/user/repo.

  2. Create a new project in RStudio, and type the code blogdown::new_site(theme = 'user/repo') in the R console, where user/repo is from the link in Step 1.

  3. Play with the new site for a while and if you do not like it, you can repeat the above steps, otherwise edit the options in config.toml. If you do not understand certain options, go to the documentation of the theme, which is often the README page of the GitHub repository. Not all options have to be changed.

To edit a website:

  1. Set options(servr.daemon = TRUE) unless you have already set it in .Rprofile. If this option does not work for you (e.g., it crashes your R session), see Section 1.4 for a workaround.

  2. Click the RStudio addin “Serve Site” to preview the site in RStudio Viewer. This only needs to be done once every time you open the RStudio project or restart your R session. Do not click the Knit button on the RStudio toolbar.

  3. Use the “New Post” addin to create a new post or page, then start writing the content.

  4. Use the “Update Metadata” addin to modify the YAML metadata if necessary.

To publish a website:

  1. Restart the R session, and run blogdown::hugo_build(). You should get a public/ directory under the root directory of your project.

  2. Log into https://www.netlify.com (you can use a GitHub account if you have one). If this is the first time you have published this website, you can create a new site, otherwise you may update the existing site you created last time. You can drag and drop the public/ folder from your file viewer to the indicated area on the Netlify web page, where it says “Drag a folder with a static site here.”

  3. Wait for a few seconds for Netlify to deploy the files, and it will assign a random subdomain of the form random-word-12345.netlify.com to you. You can (and should) change this random subdomain to a more meaningful one if it is still available.

If you are familiar with GIT and GitHub, we recommend that you create a new site from your GitHub repository that contains the source files of your website, so that you can enjoy the benefits of continuous deployment instead of manually uploading the folder every time. See Chapter 3 for more information.