Read More Link in Drupal 8 views

Drupal Views is integrated into Core for Drupal 8.  I was excited to see this since I use views in a lot of different scenarios.  However, recently I encountered an issue that seems unusually complicated for something so trivial.  The read more link, or more specifically, linking to the content itself in the view.  I have a block that uses a fields view, and trim the summary.  I want the user to be able to quickly navigate to the full article, so I need to provide a link. 

In previous versions, when trimming a field, it would give you the option to provide a link and custom text which I frequently set to read more.  In Drupal 8, it is a little different, at least at this point.  Let's go through the steps it takes. 

We need to add 2 fields to our view for the read more link

  1. Add the field Content:path to the view, this is the path alias of the node.  
    In the field configuration options, exclude it from the display, and check the "Use absolute link" checkbox under the Rewrite Results settings


     

  2. Next, add a Custom text field to the view.  Set the text to whatever you want it to be, read more, continue reading, etc. Then under the Rewrite Results settings, check the checkbox next to the option that says Ouput this field as a custom link.  Then, for the link path, use {{ path}}.  Do not check the option to use absolute path. 

    This completes the necessary steps.  If you are having trouble with the link, you can uncheck the exclude from display option on the path field to see where the link is pointing to. 

    My hope is that they will correct this in a future release, but in the meantime, I hope you found this useful.

 

 

Category: