Skip to content
/ hugodown Public

Make websites with hugo and RMarkdown

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

r-lib/hugodown

Repository files navigation

hugodown

Lifecycle: experimental R-CMD-check Codecov test coverage

hugodown is an experimental package that aims to facilitate the use of RMarkdown and hugo together. It's similar to blogdown, but is focussed purely on Hugo websites, and enforces a stricter partitioning of roles: hugodown is responsible for transforming .Rmd to .md, and hugo is responsible for transforming .md to .html.

Compared to blogdown

  • It only re-runs your R code when you explicitly ask for it (by knitting the post). This makes hugodown considerably easier to use for long-running blogs and blogs with multiple contributors.

  • Local previews are pinned to a specific version of hugo. This makes it easier to work with multiple blogs, and protects your from hugo <-> theme version incompatibilities.

  • It provides support for getting started with a limited number of themes, automatically making needed tweaks to ensure that html widgets, syntax highlighting, and math display work out of the box.

  • It does not currently support within page cross-references for figures, tables, and equations.

  • It is more opinionated about hugo configuration; see vignette("config") for details.

  • It is designed around a single Rmarkdown format, .Rmd.

Installation

hugodown isn't available from CRAN yet (and might never be), but you can install the development version from GitHub with:

devtools::install_github("r-lib/hugodown")

Usage

The key to using hugodown is to put output: hugodown::md_document() in the YAML metadata of your .Rmd files. Then knitting the file will generate a .md file designed to work well with hugo. The rest of hugodown just makes your life a little easier:

  • hugo_start() will automatically start a hugo server in the background, automatically previewing your site as you update it.

  • use_post() will create a new post (filling in default content from the hugo archetype).

  • To knit an .Rmd post, you can use the Knit button to knit to the correct output format. You can also use the keyboard shortcut Cmd+Shift+K (Mac) or Ctrl+Shift+K (Windows/Linux).

  • site_outdated() lists all .Rmd files that need to be re-rendered (i.e. they have changed since the last time their .md was rendered).

With hugodown, knitting an individual post and building the site are two separate processes. A good workflow when working with an existing Hugo site in RStudio is to open the site's .Rproj file, use hugo_start(), then add or edit your posts. Because the hugo server will only add .Rmd content to your site preview after knitting, you'll need to use the keyboard shortcut to knit first.

Citations

To use citations in a blog post, just provide a bibliography in the YAML metadata. If you want to use footnotes for citations (a style that generally works well in blogs), you'll need to find a footnote style CSL file (e.g. chicago-fullnote-bibliography.csl, and use the following YAML header.

bibliography: refs.bib
suppress-bibliography: true
csl: chicago-fullnote-bibliography.csl

Converting from blogdown

  • Make sure your post archetype has extension .Rmd and includes output: hugodown::md_document in the YAML. The post archetype should typically be archetypes/blog/index.Rmd.

  • Delete index.Rmd from the root of your site.

  • Ensure that hugo is configured as described in vignette("config").

About

Make websites with hugo and RMarkdown

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published