Learning Objectives

Motivation

Installation

Getting started

  1. Set your working directory to the location on your local machine where you want to save your website. Do this via

    Session > Set Working Directory > Choose Directory…

  2. Run the following in your R consul:

    blogdown::new_site()

Choosing a Theme

  • There are tons of themes available on the Hugo website: https://themes.gohugo.io/

  • The steps to installing a theme are:

    1. Find the GitHub username/reponame for for a theme you are interested in. On the hugo themes website you can usually find this by clicking on “homepage”.
    2. While creating your site, instead of just running blogdown::new_site(), run blogdown::new_site(theme = "username/reponame").
  • For example:

  • Note that the more complicated the theme, the more difficult it is to maintain.

  • The blogdown folks recommend first trying out these simple themes:

Editing your website

config.toml

  • Most Hugo sites contain a config.toml file, where “toml” stands for “Tom’s Obvious, Minimal Language”

  • TOML files consist of key = value pairs, where the key is the variable and the value is the assigned variable. For example

    author = "David Gerard"
  • You can usually just edit the TOML file of the theme that you have downloaded.

  • The double brackets in a TOML file are used in Hugo to denote a menu. So, for example

    [[menu.main]]
        name = "Home"
        url = "https://nanx.me"
        weight = 1
    [[menu.main]]
        name = "GitHub"
        url = "https://github.com/nanxstats"
        weight = 2

    is used to define the items in the default main menu of the Tanka theme.

  • The single brackets in a TOML file are used in Hugo to denote a collection of related options. E.g.

    [params]
        author = "David Gerard"
        dateFormat = "2020/10/10"

    will set options under [params]

content/

  • This folder is where you place R Markdown files. These R Markdown files will be converted to HTML files.

  • To add a new page to “content”, click on

    Addins > New Post

  • You can then choose the name of the file, whether you are working with a Markdown file (no R, just formatted text) or an R Markdown file, and make some additonal formatting options for the page.

  • You can change the page name to something different from the default.

  • For example, if you choose the name “resume”, then the default is that the location of the HTML file in the “public” folder will be “resume/index.html”.

    • This is instead of what you would assume to be the case, e.g. “resume.html” (NOT DONE).

     

  • The big thing for you is when you are linking to a particular page, you need to link to the location “resume/index.html”, not to “resume.html”. E.g.

Publishing your website