Overview
Theminutes_to_read macro calculates the estimated reading time for content based on an average reading speed of 300 words per minute. It outputs the reading time wrapped in customizable HTML tags.
Syntax
Parameters
A content object that contains a
post_body property with the content to analyzeHTML or text to display before the reading time number
HTML or text to display after the reading time number
Return Value
Returns a string containing the estimated reading time in minutes, wrapped in the specifiedbefore and after strings. If the reading time is less than 1 minute, returns an empty string.
Usage
Import the Macro
Basic Example
<span>5</span> (for content that takes approximately 5 minutes to read)
Custom Wrapper Tags
<span class="read-time">5 min read</span>
Plain Text Output
5 minutes
Common Use Cases
Calculation Method
The macro calculates reading time using the following formula:- Strips HTML tags from
post_bodyand counts words - Rounds word count down to nearest 100 (e.g., 847 words → 800 words)
- Divides by 300 (average words per minute)
- Rounds to 2 decimal places, then rounds to nearest whole number
- If result is less than 1, returns nothing; otherwise returns the formatted time
- Content has 1,250 words
- Rounded to 1,200 words
- 1,200 ÷ 300 = 4.00
- Rounded: 4 minutes
Implementation Details
The macro assumes an average reading speed of 300 words per minute. Very short content (less than 1 minute to read) will not display any output.
Best Practices
- Use this macro with blog posts or long-form content objects
- Ensure the content object has a
post_bodyproperty - For very short content, consider using conditional logic to display alternative text
- Customize the
beforeandafterparameters to match your design system