Building your personal website with R blogdown

Note that this article is outdated. Lots of things have changed. Please refer to the wowchemy documentation for the most updated method to create a website.

Why I chose blogdown to build my personal website

I used to host a personal website with google site, which is nice and friendly to begninners. However in certain cases, google site may not be that handy. For instance, it is not compatible with R markdown files. You are not allowed to upload html files generated by R markdown to your Google site (technically you can do this by embedding the html codes, see this, but that’s not what I wanted).

So if you plan to regularly share posts (such as html files or R markdown files) on your website, google site will probably let you down. Note that Markdown file and R markdown file are not the same though very similar, see the differences explained by Yihui.

Here comes the blogdown package, which is designed for building personal websites. More importantly, it is a package rooted in R and RStuido and fully compatible with other R components. If you are comfortable with R programming, blogdown will satisfy you.

Resources for building website with blogdown

There are countless resources and instructions available to guide you through step by step. See two good examples below.

However, before you hit the road, I’d like provide additional advice based on my experiences and hopefully you can benefit from it.

The basic idea is that you are not actually “creating” a website, instead, you customize a template. For instance, the template I used is called Hugo Academic. A collection of templates can be found from here.

After you finish the customization, you are highly recommended to deploy your website with Github and Netlify. Should you not worry about for this, because the instructions I provided above cover the whole process in details.

Long story in short, you can follow Annie Lyu’s instruction and customize your website on your local machine (this is the first step), and then upload your website folder to a newly created repository in Github (this is the second step). To do that, you can either create a new repository directly on Github, or you can take advantage of Github Desktop. The third step is to deploy using Netlify, which is quite straightforward.

Alternatively, you can also follow the step by step instruction by Wowchemy, which is the official guide to create website using hugo (the workhourse used in the blogdown package). That means the instruction is a general cookbook and is not particularly written for R blogdown. For the Wowchemy instruction, you need to set up your Github repository first and customize directly in Github. The final deploying process is similar.

The punchline is:

  • If you are comfortable with RStiduo and R markdown, you may want to follow Annie Lyu’s instruction.
  • If you are more familiar with Github, you can try the instruction by Wowchemy.

Potential problems with the template

If you follow Annie Lyu’s instruction, you may encounter problems with the gcushen/hugo-academic template. Remember to change the template to wowchemy/starter-academic. See the snapshot below.

Custermize your webiste

After you complete your webiste using the template, you can move forward to custermizing the template based on your preference. To start with, follow this instruction here to select a color theme and font theme for your website.

Then follow this instruction to custermize your homepage. You can delete unnecessary sections and create new sections based on your needs.

I know there are lots of stuff there but do not get yourself overwhelmed. Just try to play with it and you will be like a professional sooner or later.

Other tips that might be useful for you

Add publications to your website

You can either automatically add publications through *.bib BibTex files or manually add using hugo command. See the instruction from Wowchemy.

  • Automatically

    1. You need to create a list of your own publication and export it as a *.bib file. I highly recommend you do this with Zotero.

    2. If you have installed the Anaconda, that says you have Python installed on your computer. You can proceed by installing academic. To do this, open your Terminal under Anaconda (You can find it in the Window start menu, if you are using a Windows system), see the figure below.

      And then type the following command in the opened Terminal.

      pip install -U academic

      Following that, use the cd command to navigate to your website folder in the terminal.

    3. Finally, you will be able to import your publications with the command below.

      academic import --bibtex <path_to_your/publications.bib>

      Here <path_to_your/publications.bib> is the pah of your bib file. Do remove the <> while you are pasting the path to the terminal. See the figure below.

    4. Now you should be able to see your publications in the content/publication/ folder of your website folder.

      Note that the command will automatically create separate folders for each of your publications.

    5. In each of the publication folder, you can customize the file based on your needs, such as adding author_notes, tags, and publication_types.

      To highly your name in the author list, open the config\params.toml file in your website folder, and set highlight_superuser = true.

  • Manually

    Initially, I did not go over the approach of manually adding publications. However, later on, I figured out it’s quite useful when you have updates on your publication list such as a working paper or new publications. In these cases, the manually adding approach is handy and more convenient. Below I follow the instruction in Wowchemy and briefly show you how to do the task. It’s very simple and just one line of code.

    1. Follow the second step in the automatically adding publication approach and open your Terminal under Anaconda.

    2. Before you type any commands in the terminal, you need to first navigate to your website folder using the cd command (see the second step in the automatic adding method).

    3. Then you simply type the code below to add your working papers and new publications, where <my-publication> is the name of your publication, using hyphens (-) instead of spaces. Again do remember to remove the <>.

    hugo new --kind publication publication/<my-publication>

    This command will automatically create a publication file in your content/publication/<my-publication>/ folder. You can customize and add your inputs to the Your updates will show up on your website after you deploy it.