Skip to content

blogdown 1.0

Compare
Choose a tag to compare
@yihui yihui released this 09 Jan 07:35

NEW FEATURES

  • Added a function check_site() to provide diagnostics for a website project, which may help reveal potential problems in various places. It runs a series of checks on the config file (config.yaml or config.toml), the .gitignore file, the Hugo installation and version, the netlify.toml file, and content files. See the help page ?blogdown::check_site for more info.

  • Documented and exported the internal function find_hugo() to find the Hugo executable. If multiple versions of Hugo are installed, find_hugo() can also find a specific version of Hugo, e.g., blogdown::find_hugo('0.25.1'). You may use blogdown::find_hugo('all') to find all possible versions of Hugo currently installed.

  • Added a function remove_hugo() to remove Hugo (thanks, @cderv, #504).

  • The file format .Rmarkdown supports HTML widgets and citations now, just like the .Rmd format. If you are not familiar with the .Rmarkdown format, you may see https://bookdown.org/yihui/blogdown/output-format.html.

  • Added a function config_netlify() to help users create the config file netlify.toml for Netlify. It sets the build commands properly for different deploy contexts, and writes the local Hugo version to the config file, so make sure Netlify uses the same version of Hugo as your local environment. See the help page ?blogdown::config_netlify for details.

  • Added a function config_Rprofile() to help create or modify the .Rprofile file. In particular, it will try to set the option blogdown.hugo.version in it, if the option has not been set. See the help page ?blogdown::config_Rprofile for details.

  • Added an argument netlify = TRUE to new_site() to create netlify.toml by default.

  • Added an argument .Rprofile = TRUE to new_site() to create the .Rprofile file by default. This file contains a few sample global options that could affect blogdown's behavior, e.g., the option blogdown.hugo.version is set to the current Hugo version, so that a site will not be affected by future Hugo updates and will always use the fixed version of Hugo. This file is provided so that users are better aware of some of these options, and can change them if they want.

  • Exported the function filter_newfile(), which returns paths of source files that have not been knitted (i.e., their output files do not exist).

  • The build_rmd argument of build_site() can take a function as its value now (thanks, Tyler Smith). The function is expected to take a vector of paths of all R Markdown files under the content/ directory, and returns a vector of paths of R Markdown files to be built. This argument can also take one of the aliases "timestamp", which is equivalent to blogdown::filter_timestamp, newfile (equivalent to blogdown::filter_newfile), and "md5sum" (equivalent to blogdown::filter_md5sum). For example, blogdown::build_site(build_rmd = "timestamp") means to build all R Markdown files if they are older than their output files (by comparing modification times).

  • When opening a blogdown website project in RStudio, you can specify a number of files to be automatically opened every time via the global option blogdown.initial_files in your .Rprofile. This option can take a vector of file paths, e.g., options(blogdown.initial_files = c('config.yaml', '.Rprofile', 'content/post/my-first-post/index.Rmd')) (files that do not exist will be ignored). Alternatively, this option can take a function that returns a vector of file paths, e.g., options(blogdown.initial_files = blogdown:::initial_files).

  • Added a new argument .site_dir to serve_site(), so users will be able to specify the site root directory (thanks, @Bijaelo, #527).

  • Added a new argument force to new_site() to allow users to create a new site under a nonempty directory with force = TRUE if they are sure the site can be safely created under the directory (i.e., Hugo will not possibly override existing files). In an interactive R session, it will ask users if they want force = TRUE when the directory is not empty.

MAJOR CHANGES

  • install_hugo() no longer installs Hugo via Homebrew by default on macOS, but just downloads binaries from Hugo's Github releases, which gives you a stable version of Hugo. The use_brew argument of install_hugo() has been deprecated. Installing Hugo via Homebrew often leads to accidental updates of Hugo, which may break your existing sites. If you must install Hugo via Homebrew and want to fix its version, you can run brew pin hugo, so it will not be updated by accident in the future (e.g., via brew upgrade).

  • By default, install_hugo() installs Hugo to ~/.local/share/Hugo on Linux now, instead of ~/bin.

  • install_hugo() installs the hugo executable to a directory with the directory name being the Hugo version number, e.g., ~/Library/Application Support/Hugo/0.76.5, or ~/.local/share/Hugo/0.25.1. This makes it possible to install multiple versions of Hugo on the same computer.

  • When starting to serve the site, serve_site() will compile Rmd files that do not have output files initially (thanks, Hannah Wang, https://stackoverflow.com/q/64420476/559676).

  • The default value of the global option blogdown.serve_site.startup was changed from TRUE to FALSE, meaning that the site will not by served by default when the RStudio project is first opened. If you want the previous behavior, you may set options(blogdown.serve_site.startup = TRUE) in your .Rprofile.

  • The method argument of build_site() was deprecated. The build method can only be specified via the global option blogdown.method now, e.g., you may set options(blogdown.method = 'custom') in .Rprofile. A new possible build method named markdown was added. When you set options(blogdown.method = 'markdown'), .Rmd posts will be compiled to .md (by default, they are compiled to .html since the default option is blogdown.method = 'html'). This provides another way to render R Markdown to Markdown instead of HTML. Previously, the only way to achieve this was to use the file extension .Rmarkdown (this way still works).

  • The function update_hugo() and the argument force of install_hugo() have been deprecated. If you want to update Hugo to a newer version, you can call install_hugo() and specify a desired version.

  • The functions md5sum_filter and timestamp_filter have been renamed to filter_md5sum and filter_timestamp, respectively.

BUG FIXES

  • serve_site() fails to start the server when the config file contains a baseURL value that includes a subpath in it (thanks, @giabaio #254, @ShixiangWang #494).

  • serve_site() and hugo_build() fail to resolve URLs when relativeURLs is configured to true (thanks, @TianyiShi2001, #506).

  • The "Insert Image" addin works with posts that are index pages of leaf bundles now. The images are added to the images/ folder under the post directory by default instead of the top-level static/ directory (thanks, @amssljc, #499).

  • For a post that is the index page of a bundle, its images could not be displayed when the post content is displayed on other pages such as the home page (thanks, @andremrsantos #501, Fabio A. Cruz Sanchez https://stackoverflow.com/q/65097597/559676).

  • The _files/ and _cache/ folders are not correctly moved for index pages of leaf bundles when the filename of an index page contains a language code such as index.en.Rmd (thanks, @cderv, #500).

  • install_hugo() could not install the extended version of Hugo that was downloaded manually, e.g., blogdown::install_hugo('~/Downloads/hugo_extended_0.78.2_Linux-64bit.tar.gz') would fail (thanks, Stuart, https://stackoverflow.com/q/64962659/559676).

  • new_post(date = "") or new_post(date = NULL) failed to work. In both cases, it should create a post without the date field in the YAML metadata (thanks, Caleb Stevens, https://stackoverflow.com/q/65067164/559676).

  • new_site() no longer shows Hugo messages on Windows (#532).

  • new_site() can figure out the default branch name of a theme repo now, instead of assuming the master branch is the default (thanks, @c1au6i0, #541).

MINOR CHANGES

  • For new_site(to_yaml = TRUE), it will also convert config.toml to config.yaml.

  • The default value of the serve argument in new_site() was changed from TRUE to "ask" in an interactive R session, which means it will ask if users want to serve the site after creating it.

  • The default value for the format argument of new_site() was changed from toml to yaml, which means it will generate config.yaml instead of config.toml by default.

  • new_site() will create two sample scripts R/build.R and R/build2.R (they can be deleted if you don't need them). See the help page ?blogdown::build_site for their meanings.

  • Autocomplete is supported for the names of important global options when typing inside options() in RStudio, e.g., when typing options(blogdown.au), RStudio will show the candidate blogdown.author.

  • read_toml() and toml2yaml() will try to preserve the original order of fields in the TOML data, instead of using the alphabetical order.

  • When clicking the "Build Website" button in RStudio, it will no longer open the index.html file in the generated site folder, but emit a message telling users that this folder needs to be served before the web pages can be correctly previewed (#522).

  • For Jekyll sites, the arguments --watch, --incremental, and --livereload are passed to jekyll serve by default. These arguments can be set via the global R option blogdown.jekyll.server.

  • The meta variable link-citations is set to true for the pandoc_args argument of blogdown::html_page(), so that links can be generated on citation items by default.

  • The internal function Rscript() was removed and it is publicly available in the xfun package now. If you need this function, please use xfun::Rscript() instead.

  • Removed internal functions is_windows(), is_osx(), and is_linux(). They are available in the xfun package now (note that is_osx() has become xfun::is_macos()).