Skip to main content

The related_blog_posts HubL tag can be used to create dynamic and related blog post listing based on a variety of parameters. It allows for generating listings of posts across blogs, with the ability to filter by tags, authors, post paths and publish dates. Developers can also specify the HTML output of the module using a macro. This HubL tag can be used on both blog posts and pages. This tutorial will walk through the parameters and usage options for the blog related posts HubL tag.

The list of posts is generated from a relevancy score based on a comparison of the set parameter values against posts matching these parameters, or relating to the post the HubL tag appears on. None of the parameters are required, however, specifying parameters will allow you to further control which posts are returned. For comma-separated parameters, the more values you set, the more diverse the returned listing will be. The post_formatter parameter allows you to specify a macro to generate the HTML output of the module. For a full list of parameters and example default HTML output, please see the related_blog_posts spec.

ParameterTypeDescriptionDefault
limitnumberThe max number of blog posts to list.3
blog_ids'default' or blog idThe ID(s) of a blogs to include posts from.none
tagsStringThe tag(s) that should be used to determine if a post is relevant (comma separated). If a blog post has one of these tags or a similar tag, the post’s relevancy is increased, improving its ranking in the listing.none
blog_authorsStringThe names of authors to include posts from (comma separated)none
blog_post_idsStringThe ID(s) of a blog posts to use when finding relevant blog posts to list (comma separated). This parameter should only be used when the widget is appearing on pages, as on blog posts, it will default to the post the widget is appearing on.none
post_formatterStringThe name of a custom macro to render returned blog posts. The macro is passed three parameters which are the blog post object to format, the count in the iteration of blog posts, and the total count of blog posts in the results. If not specified or set to “default”, the built-in formatter will be used to format each post.

Note: It is recommended to use the callback parameter below in place of the ‘post_formatter’ parameter as the HTML of the tag will render more quickly, decreasing page load times.
none
callbackStringThe name of a javascript function to render returned blog posts. The function is passed an array of blog post objects to format. If neither the callback, or post_formatter parameters are specified, the tag will generate HTML in a default format.none
path_prefixesStringURL paths or subdirectories to include posts from (comma separated). If a blog post has a similar prefix in its path, the post’s relevancy is increased, improving its ranking in the listing.none
start_datedate/timeAllows for filtering of posts published after a date/time.none
end_dateDate/TimeAllows for filtering of posts published before a date/time.False
blog_post_overrideStringThe ID(s) of a blog posts which should always show up in the returned listing, despite all other parameter values and filters (comma separated).none

Below are some example ways to use this tag to enhance your website.

In this example, we generate a listing of posts written by one of the three specified blog_authors across two different blogs.

In this example, we generate a listing of 10 posts related to a specific blog post, with the tag "sales enablement", and restricted to a specific publish date time frame. This example specifies the blog_post_ids parameter, so it would be used on a page.

In this example, we generate a listing of 5 posts using the callback parameter to control the HTML output of the post listing. (Instead of the post_formatter parameter using a macro.)