Create a new post

Add to your blog using this workflow.

/posts folder

Posts folder in the blog directory

Folders inside the posts folder

QMD files inside of the individual posts folders

Creating a new post

flowchart LR
  A{Create a new folder under your listing folder} --> B(Create a new blog post with the title `index.qmd` in the folder)
  A --> C(Optionally, create a `_metadata.yml` file that creates shared metadata for all documents in the folder)

New post workflow

You can create a new folder and index.qmd file using RStudio:

Or using the command line:

mkdir posts/new-post
touch posts/new-post/index.qmd
  • In the default project created by RStudio, the listing folder is called /posts.
  • The folder name will be the “slug” (i.e., part of the URL that identifies the page)
Post name & location Slug
/posts/what-is-quarto/index.qmd www.mysitename.com/posts/what-is-quarto
/posts/what-is-quarto/post01.qmd www.mysitename.com/posts/what-is-quarto/post01.html

/posts folder

_metadata.yml file

# options specified here will apply to all posts in this folder

# freeze computational output
# (see https://quarto.org/docs/projects/code-execution.html#freeze)
freeze: true

# Enable banner style title blocks
title-block-banner: true
  • freeze
    • freeze: true: Re-render during project render only when explicitly re-rendered.
    • freeze: auto: Re-render only when source changes.
  • title-block-banner: creates a banner style title block.
  title-block-banner: "#FFDDFF"

  title-block-banner: "banner.jpg"

Try it out!

In the /posts/_metadata.yml file of your Quarto blog:

  • Change the color of title-block-banner to "#FFA500".
  • Change it again to banner.jpg.

/posts/index.qmd file

---
title: "Welcome To My Blog"
author: "Tristan O'Malley"
date: "2022-08-21"
categories: [news]
---

title

The title of the post.

author

The author of the post.

author: Haku
author:
  - Haku
  - Poki
  - Pichi
  - Nagi
author: [Haku, Poki, Pichi, Nagi]

date

The date of the post.

categories

The enabled categories. You can have multiple:

categories: how-to
categories:
  - tutorial
  - how-to
categories: [tutorial, how-to]

Drafts

Add draft: true to the document options to not include a post in the listing, site map, or site search. For example:

---
title: "Welcome To My Blog"
author: "Tristan O'Malley"
date: "2022-08-21"
categories: [news]
draft: true
---

Quarto listing fields documentation

Try it out!

rstd.io/quarto-blog-exercise-repo
Launch RStudio Cloud rstd.io/quarto-blog-exercise-cloud

  • Create a new post in a folder called my-first-post with the title index.qmd.
  • Create the YAML for the post: title, author, and date.

Preview/render the website and check out the listing page.

Below the YAML, you will write your post.