In RStudio web pages are built from the Rmarkdown (.Rmd) files. So,

When we use the Build button, the rmarkdown files are converted to html. Those html files become the pages of the website in the site structure.

The structure of the site is contained in the file _site.yml. It looks like this.

name: "Create a simple Rmarkdown website"
output:
  html_document:
    theme: cosmo
    #highlight: textmate
navbar:
  left:
    - text: "Home"
      href: index.html
    - text: "Next Steps"
      menu: 
        - text: "Writing Pages"
          href: writepage.html 
        - text: "Include Images"
          href: images.html
        - text: "Embed a webpage"
          href: embed.html
        - text: "Embed an infographic"
          href: info.html
    - text: "Change the Structure"   
      menu:
        - text: "Site structure"
          href: structure.html
    - text: "Publish to Github"      
      menu: 
        - text: "publish"
          href: publish.html
        - text: "submenu item"
          href: yourfile.html
output_dir: "."

The basics

The site structure starts with the name of the site. Then we have the output as html_document and a theme. For available themes see the RStudio websites section. You can also choose the text highlight option (commented out with # here).

Next comes location of the navigation bar.

The index file

All websites must have an index file. In this case the - text: provides the instruction on what to call the menu item "Home". Below that we have the reference to the html file that corresponds with home. To build a website on GitHub you must have an index file, so this goes here.

An important point here is that the indents matter. If they are slightly out the site will create an error or not display properly. Use the tab key to make sure things are properly aligned.

- text: "Home"
  href: index.html

output_dir

This is set to “.” if you want to publish the site on GitHub. For other options see the Publishing Websites section of the RStudio guide.