It's easy to set up and use slugs ... at a high-level this recipe uses a Content Channel View block to list the content channel items and build out links to a detail page. The detail page uses the slug to show a particular content item in a Content Channel Item View block.

Summary

If your site already has content channel listing and detail pages (hint: it probably does, out of the box when you installed Rock) for a given content channel, and you've assigned the detail page to the listing page in the content channel view block then all you need to link to the detail page using slugs is ...

{% comment %} slugLinks {% endcomment %}
{% for item in Items %}
        {% assign seriesSlug = item.PrimarySlug %}
        <a class="your-styling-className" href="{{ LinkedPages.DetailPage }}{% if seriesSlug and seriesSlug != empty %}/{{ seriesSlug }}{% else %}?Item={{ item.Id }}{% endif %}">
            {% comment %} Here's where you'll add your link text {% endcomment %}
            {{ item.Title }}
            {% comment %} Anything else you're displaying in your links {% endcomment %}
        </a>
{% endfor %}

... somewhere in the lava template of the Listing Page's Content Channel View block.

Above, we're checking to make sure we have a slug on the item, and defaulting to the ?Item=item.Id that comes out of the box with Rock's podcast example.

TL;DR

If you're not at all familiar with Rock's content channels, everything we're here can be found in more detail on RockRMS.

The Listing Page

At a minimum, you'll need a Content Channel View block on the listing page. This block will display all the content channel items you want to link to using slugs.

The Content Channel View Block

  • Choose the content channel - In this example it's the Podcast Series.
  • Add the Lava Template - in this example we're including the Lava Template from a file, but you could just add the lava here too. In this template is where you need the slugLinks summary above.
  • Select the Detail Page that will display the item's detail.
  • Add Filters (optional) - Hopefully you're already familiar with this part. If not, check out RockRMS again.

The Detail Page

You need a route on this page that includes the {slug}. In this example it's message/{slug}.

You should have access to all of the properties and attributes of your content item using Item. For more information on the Content Channel Item View block visit RockRMS again.