find_project_root: Find the root of a Quarto project

View source: R/utils-projects.R

find_project_rootR Documentation

Find the root of a Quarto project

Description

This function checks if the current working directory is within a Quarto project by looking for Quarto project files (⁠_quarto.yml⁠ or ⁠_quarto.yaml⁠). Unlike get_running_project_root(), this works both during rendering and interactive sessions.

Usage

find_project_root(path = ".")

Arguments

path

Character. Path to check for Quarto project files. Defaults to current working directory.

Value

Character Path of the project root directory if found, or NULL

See Also

get_running_project_root() for detecting active Quarto rendering

Examples


tmpdir <- tempfile()
dir.create(tmpdir)
find_project_root(tmpdir)
quarto_create_project("test-proj", type = "blog", dir = tmpdir, no_prompt = TRUE, quiet = TRUE)
blog_post_dir <- file.path(tmpdir, "test-proj", "posts", "welcome")
find_project_root(blog_post_dir)

xfun::in_dir(blog_post_dir, {
  # Check if current directory is a Quarto project or in one
  !is.null(find_project_root())
})

# clean up
unlink(tmpdir, recursive = TRUE)



quarto documentation built on Sept. 9, 2025, 5:52 p.m.