hugo_cmd {blogdown} | R Documentation |
Run Hugo commands
Description
Wrapper functions to run Hugo commands via system2('hugo',
...)
.
Usage
hugo_cmd(...)
hugo_version()
hugo_available(version = "0.0.0", exact = FALSE)
hugo_build(
local = FALSE,
args = getOption("blogdown.hugo.args"),
baseURL = NULL,
relativeURLs = NULL
)
new_site(
dir = ".",
force = NA,
install_hugo = TRUE,
format = "yaml",
sample = TRUE,
theme = "yihui/hugo-lithium",
hostname = "github.com",
theme_example = TRUE,
empty_dirs = FALSE,
to_yaml = TRUE,
netlify = TRUE,
.Rprofile = TRUE,
serve = if (interactive()) "ask" else FALSE
)
new_content(path, kind = "", open = interactive())
new_post(
title,
kind = "",
open = interactive(),
author = getOption("blogdown.author"),
categories = NULL,
tags = NULL,
date = Sys.Date(),
time = getOption("blogdown.time", FALSE),
file = NULL,
slug = NULL,
title_case = getOption("blogdown.title_case"),
subdir = getOption("blogdown.subdir", "post"),
ext = getOption("blogdown.ext", ".md")
)
hugo_convert(to = c("YAML", "TOML", "JSON"), unsafe = FALSE, ...)
hugo_server(host, port)
Arguments
... |
Arguments to be passed to |
version |
A version number. |
exact |
If |
local |
Whether to build the site for local preview (if |
args |
A character vector of command-line arguments to be passed to
|
baseURL , relativeURLs |
Custom values of |
dir |
The directory of the new site. |
force |
Whether to create the site in a directory even if it is not
empty. By default, |
install_hugo |
Whether to install Hugo automatically if it is not found. |
format |
The format of the configuration file, e.g., |
sample |
Whether to add sample content. Hugo creates an empty site by default, but this function adds sample content by default. |
theme |
A Hugo theme on Github (a character string of the form
|
hostname |
Where to find the theme. Defaults to |
theme_example |
Whether to copy the example in the ‘exampleSite’ directory if it exists in the theme. Not all themes provide example sites. |
empty_dirs |
Whether to keep the empty directories generated by Hugo. |
to_yaml |
Whether to convert the metadata of all posts to YAML. |
netlify |
Whether to create a Netlify config file ‘netlify.toml’. |
.Rprofile |
Whether to create a ‘.Rprofile’ file. If |
serve |
Whether to start a local server to serve the site. By default, this function will ask you in an interactive R session if you want to serve the site. |
path |
The path to the new file under the ‘content’ directory. |
kind |
The content type to create, i.e., the Hugo archetype. If the
archetype is a page bundle archetype, it should end with a slash, e.g.,
|
open |
Whether to open the new file after creating it. By default, it is opened in an interactive R session. |
title |
The title of the post. |
author |
The author of the post. |
categories |
A character vector of category names. |
tags |
A character vector of tag names. |
date |
The date of the post. |
time |
Whether to include the time of the day in the |
file |
The filename of the post. By default, the filename will be
automatically generated from the title by replacing non-alphanumeric
characters with dashes, e.g. |
slug |
The slug of the post. By default ( |
title_case |
A function to convert the title to title case. If
|
subdir |
If specified (not |
ext |
The filename extension (e.g., ‘.md’, ‘.Rmd’, or
‘.Rmarkdown’). Ignored if |
to |
A format to convert to. |
unsafe |
Whether to enable unsafe operations, such as overwriting
Markdown source documents. If you have backed up the website, or the
website is under version control, you may try |
host , port |
The host IP address and port; see
|
Functions
-
hugo_cmd()
: Run an arbitrary Hugo command. -
hugo_version()
: Return the version number of Hugo if possible, which is extracted from the output ofhugo_cmd('version')
. -
hugo_available()
: Check if Hugo of a certain version (or above ifexact = FALSE
) is available. -
hugo_build()
: Build a plain Hugo website. Note that the functionbuild_site()
first compiles Rmd files, and then calls Hugo viahugo_build()
to build the site. -
new_site()
: Create a new site (skeleton) viahugo new site
. The directory of the new site should be empty, -
new_content()
: Create a new (R) Markdown file viahugo new
(e.g. a post or a page). -
new_post()
: A wrapper function to create a new post under the ‘content/post/’ directory vianew_content()
. If your post will use R code chunks, you can setext = '.Rmd'
or the global optionoptions(blogdown.ext = '.Rmd')
in your ‘~/.Rprofile’. Similarly, you can setoptions(blogdown.author = 'Your Name')
so that the author field is automatically filled out when creating a new post. -
hugo_convert()
: A wrapper function to convert source content to different formats viahugo convert
. -
hugo_server()
: Start a Hugo server.
References
The full list of Hugo commands: https://gohugo.io/commands, and themes: https://themes.gohugo.io.
Examples
blogdown::hugo_available("1.2.3")
if (interactive()) blogdown::new_site()