Is it possible to have a URI like this: /artist/{slug}/news to create an overview of all news articles of this particular artist?

I tried to set it up with Routes and with a section Entry URI, but I get a 404

1 Answer 1


You can achieve this by writing a module and using the UrlManager::EVENT_REGISTER_SITE_URL_RULES event.

Basic example:


use craft\elements\Entry;
use craft\events\RegisterUrlRulesEvent;
use craft\web\UrlManager;
use yii\base\Event;

class CustomModule
    public function init()

            static function (RegisterUrlRulesEvent $event) {
                $artistEntries = Entry::find()->section('artists')->all();

                foreach ($artistEntries as $artistEntry) {
                    $event->rules[$artistEntry->uri] = ['template' => '_pages/artists/news'];

Then, in the _pages/artists/news.twig template, you'll need to extract the artist's slug from craft.app.request.url and use it to get the Entry corresponding to your artist.

  • Thanks very much!
    – Matthias
    Commented Sep 25, 2020 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.