Skip to content

Metrics

Starlight Blog can display various metrics alongside blog posts, such as an estimated reading time or a word count.

Configure metrics

Metrics can be configured inside the astro.config.mjs configuration file of your project using the metrics option of the starlightBlog plugin.

Different metrics can be enabled or disabled:

  • readingTime — Controls whether or not the estimated reading time of blog posts are displayed.
  • words — Controls whether or not the word count of blog posts are displayed.
starlightBlog({
metrics: {
readingTime: true,
words: 'total',
},
})

See the Metrics configuration Reference for all supported options. Metrics can also be overridden on a per-blog post basis using the metrics frontmatter property and is also accessible in blog data.

About metrics

Metrics are computed by the Starlight Blog plugin based on the content of blog posts with the following rules:

  • Code blocks are ignored.
  • Any markup is stripped from the content.

The word count is calculated using the Intl.Segmenter API taking into account the language of blog posts.

The estimated reading time is calculated based on the average reading speed of 213 words per minute. Images follow the Medium reading time rules where the first image adds 12 seconds, the second image adds 11 seconds, and each subsequent image adds one less second until the tenth image, after which each additional image counts as 3 seconds.