Skip to main content

How To Create Related Posts in Drupal 8, 9 and 10

Submitted by admin on Sat, 07/30/2022 - 23:06
Related Posts in Drupal 8, 9 and 10

In this drupal tutorial we will learn how to show related articles / posts on a Drupal 8, 9 and 10 website. We will not use any additional module for this. We will only use view module, which is a Drupal core module. Related posts will be posts from the same category.

The related posts are designed to be placed below the main article. Your site visitors might be interested in reading these related posts.

Step 1: Create View

Create a new view that will display related posts.

Navigate to:
Administration >> Structure >> Views

Click Add view button.


Step 2: View Settings

Use below view settings for creating the view.

  • View name: Related Posts
  • Show: Content of type Article shorted by Newest first
  • Block Settings: Unformatted list of titles (linked)


Step 3: Add Contextual filters

Under Advanced section, add a Contextual filters.


Select Has taxonomy term ID and click Add and configure contextual filters


Step 4: Configure contextual filter

  • Select Provide default value
  • For Type select Taxonomy term ID from URL
  • Also select Load default filter from node page, that's good for related taxonomy blocks
  • And select Limit terms by vocabulary and select the Vocabulary that you use for categorising articles.


Step 5: Place the block.

We are almost done. Now we will place this view block below the content.

Navigate to:
Administration >> Structure >> Block layout

And place this newly created view block Related Posts below Main page content.


Step 6: Clear cache

We may need to clear Drupal cache.

Navigate to below and clear cache.
Administration >> Configuration >> Development >> Performance


Open any article page and you should find the Related Posts below the page content.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.