forked from rstudio/blogdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hugo_cmd.Rd
164 lines (124 loc) · 6.06 KB
/
hugo_cmd.Rd
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hugo.R
\name{hugo_cmd}
\alias{hugo_cmd}
\alias{hugo_version}
\alias{hugo_build}
\alias{new_site}
\alias{new_content}
\alias{new_post}
\alias{hugo_convert}
\alias{hugo_server}
\title{Run Hugo commands}
\usage{
hugo_cmd(...)
hugo_version()
hugo_build(local = FALSE)
new_site(dir = ".", install_hugo = TRUE, format = "toml", sample = TRUE,
theme = "yihui/hugo-lithium-theme", theme_example = TRUE,
serve = interactive(), hostname = "github.com")
new_content(path, kind = "default", open = interactive())
new_post(title, kind = "default", 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{
\item{...}{Arguments to be passed to \code{system2('hugo', ...)}, e.g.
\code{new_content(path)} is basically \code{hugo_cmd(c('new', path))} (i.e.
run the command \command{hugo new path}).}
\item{local}{Whether to build the site for local preview (if \code{TRUE}, all
drafts and future posts will also be built, and the site configuration
\code{baseurl} will be set to \code{/} temporarily).}
\item{dir}{The directory of the new site. It should be empty or only contain
hidden files, RStudio project (\file{*.Rproj}) files, \file{LICENSE},
and/or \file{README}/\file{README.md}.}
\item{install_hugo}{Whether to install Hugo automatically if it is not found.}
\item{format}{The format of the configuration file. Note that the frontmatter
of the new (R) Markdown file created by \code{new_content()} always uses
YAML instead of TOML.}
\item{sample}{Whether to add sample content. Hugo creates an empty site by
default, but this function adds sample content by default).}
\item{theme}{A Hugo theme on Github (a chararacter string of the form
\code{user/repo}, and you can optionally sepecify a GIT branch or tag name
after \code{@}, i.e. \code{theme} can be of the form
\code{user/repo@branch}). If \code{theme = NA}, no themes will be
installed, and you have to manually install a theme.}
\item{theme_example}{Whether to copy the example in the \file{exampleSite}
directory if it exists in the theme. Not all themes provide example sites.}
\item{serve}{Whether to start a local server to serve the site.}
\item{hostname}{Where to find the theme. Defaults to \code{github.com}; specify
if you wish to use an instance of GitHub Enterprise.}
\item{path}{The path to the new file under the \file{content} directory.}
\item{kind}{The content type to create.}
\item{open}{Whether to open the new file after creating it. By default, it is
opened in an interactive R session.}
\item{title}{The title of the post.}
\item{author}{The author of the post.}
\item{categories}{A character vector of category names.}
\item{tags}{A character vector of tag names.}
\item{date}{The date of the post.}
\item{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. \code{title = 'Hello World'} may create a file
\file{content/post/2016-12-28-hello-world.md}. The date of the form
\code{YYYY-mm-dd} will be prepended if the filename does not start with a
date.}
\item{slug}{The slug of the post. By default (\code{NULL}), the slug is
generated from the filename by removing the date and filename extension,
e.g., if \code{file = 'post/2015-07-23-hi-there.md'}, \code{slug} will be
\code{hi-there}. Set \code{slug = ''} if you do not want it.}
\item{title_case}{A function to convert the title to title case. If
\code{TRUE}, the function is \code{tools::\link[tools]{toTitleCase}()}).
This argument is not limited to title case conversion. You can provide an
arbitrary R function to convert the title.}
\item{subdir}{If specified (not \code{NULL}), the post will be generated
under a subdirectory under \file{content/}. It can be a nested subdirectory
like \file{post/joe/}.}
\item{ext}{The filename extension (e.g., \file{.md}, \file{.Rmd}, or
\file{.Rmarkdown}). Ignored if \code{file} has been specified.}
\item{to}{A format to convert to.}
\item{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 \code{unsafe = TRUE}.}
\item{host, port}{The host IP address and port; see
\code{servr::\link{server_config}()}.}
}
\description{
Wrapper functions to run Hugo commands via \code{\link{system2}('hugo',
...)}.
}
\section{Functions}{
\itemize{
\item \code{hugo_cmd}: Run an arbitrary Hugo command.
\item \code{hugo_version}: Return the version number of Hugo if possible, which is
extracted from the output of \code{hugo_cmd('version')}.
\item \code{hugo_build}: Build a plain Hugo website. Note that the function
\code{\link{build_site}()} first compiles Rmd files, and then calls Hugo
via \code{hugo_build()} to build the site.
\item \code{new_site}: Create a new site (skeleton) via \command{hugo new
site}. The directory of the new site should be empty,
\item \code{new_content}: Create a new (R) Markdown file via \command{hugo new}
(e.g. a post or a page).
\item \code{new_post}: A wrapper function to create a new post under the
\file{content/post/} directory via \code{new_content()}. If your post will
use R code chunks, you can set \code{ext = '.Rmd'} or the global option
\code{options(blogdown.ext = '.Rmd')} in your \file{~/.Rprofile}.
Similarly, you can set \code{options(blogdown.author = 'Your Name')} so
that the author field is automatically filled out when creating a new post.
\item \code{hugo_convert}: A wrapper function to convert source content to
different formats via \command{hugo convert}.
\item \code{hugo_server}: Start a Hugo server.
}}
\examples{
library(blogdown)
if (interactive()) new_site()
}
\references{
The full list of Hugo commands: \url{https://gohugo.io/commands},
and themes: \url{http://themes.gohugo.io}.
}