hugo_cmd: Run Hugo commands

Description Usage Arguments Functions References Examples

View source: R/hugo.R

Description

Wrapper functions to run Hugo commands via system2('hugo', ...).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
hugo_cmd(...)

hugo_version()

hugo_build(local = FALSE)

new_site(
  dir = ".",
  install_hugo = TRUE,
  format = "toml",
  sample = TRUE,
  theme = "yihui/hugo-lithium",
  hostname = "github.com",
  theme_example = TRUE,
  empty_dirs = FALSE,
  to_yaml = TRUE,
  serve = interactive()
)

new_content(path, kind = "", open = interactive())

new_post(
  title,
  kind = "",
  open = interactive(),
  author = getOption("blogdown.author"),
  categories = NULL,
  tags = NULL,
  date = Sys.Date(),
  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 system2('hugo', ...), e.g. new_content(path) is basically hugo_cmd(c('new', path)) (i.e. run the command hugo new path).

local

Whether to build the site for local preview (if TRUE, all drafts and future posts will also be built, and the site configuration baseurl will be set to / temporarily).

dir

The directory of the new site. It should be empty or only contain hidden files, RStudio project (‘*.Rproj’) files, ‘LICENSE’, and/or ‘README’/‘README.md’.

install_hugo

Whether to install Hugo automatically if it is not found.

format

The format of the configuration file. Note that the frontmatter of the new (R) Markdown file created by new_content() always uses YAML instead of TOML.

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 chararacter string of the form user/repo, and you can optionally specify a GIT branch or tag name after @, i.e. theme can be of the form user/[email protected]). You can also specify a full URL to the zip file of the theme. If theme = NA, no themes will be installed, and you have to manually install a theme.

hostname

Where to find the theme. Defaults to github.com; specify if you wish to use an instance of GitHub Enterprise. You can also specify the full URL of the zip file in theme, in which case this argument is ignored.

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.

serve

Whether to start a local server 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., post/.

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.

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. title = 'Hello World' may create a file ‘content/post/2016-12-28-hello-world.md’. The date of the form YYYY-mm-dd will be prepended if the filename does not start with a date.

slug

The slug of the post. By default (NULL), the slug is generated from the filename by removing the date and filename extension, e.g., if file = 'post/2015-07-23-hi-there.md', slug will be hi-there. Set slug = '' if you do not want it.

title_case

A function to convert the title to title case. If TRUE, the function is tools::toTitleCase()). This argument is not limited to title case conversion. You can provide an arbitrary R function to convert the title.

subdir

If specified (not NULL), the post will be generated under a subdirectory under ‘content/’. It can be a nested subdirectory like ‘post/joe/’.

ext

The filename extension (e.g., ‘.md’, ‘.Rmd’, or ‘.Rmarkdown’). Ignored if file has been specified.

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 unsafe = TRUE.

host, port

The host IP address and port; see servr::server_config().

Functions

References

The full list of Hugo commands: https://gohugo.io/commands, and themes: http://themes.gohugo.io.

Examples

1
2

Example output



blogdown documentation built on March 13, 2020, 3:25 a.m.