Help with creating dynamic routing

Hi,

I want to create a tutorial kind of a website.

I want to have the following three level structure of the same.

There is a topic, say, math.
Each topic has some course in it, say, ‘beginner math’.
Each course have some posts, say, ‘algebric-operations’.

I want to have a post url of the type “/topic/math/begineer-math/algebric-operations/” (/topic/{topic_name}/{course_name}/{post_slug}/.)

/topic/ : shows all topics
/topic/{topic_name}/: shows all courses of a the topic
/topic/{topic_name}/{course_name}/: shows all the posts of a course
/topic/{topic_name}/{course_name}/{post_slug}/: shows the post detail defined by slug

Any ideas on how the same can be achieved?

Hey @Vishal_Kumar_Mishra! At the moment there’s no easy way to support such url format, because collection paths/sub-paths are static.

What you can try doing with current dynamic routing, is have a collections for each most nested url and use static routes (configured routes key) to define the parent index pages with filter by tag.

Hello @naz,

Thank you very much for the support. This is how my routes.yaml file looks like.

# list of primary tags
topic_list: 
  - math
  - python
  - ubuntu
  - algorithm
  - data-structure

routes:

  /:
    controller: channel
    template: index

  /math/beginner-math/:
    controller: channel
    filter: primary_tag:beginner-math



collections:

  /math/:
    permalink: /math/{primary_tag}/{slug}/
    template: index
    filter: tag:math + tag:-topic_list-math

  /python/:
    permalink: /python/{primary_tag}/{slug}/
    template: index
    filter: tag:python + tag:-topic_list-python
  


# use this to manipulate how tag and author archive appear
taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

This seems to be working till now, but I wish I could do something like the following in .yaml file.

`# syntax inspired from Python`
    for item in topic_list:
      /item/:
        permalink: /item/{primary_tag}/{slug}/
        template: index
        filter: tag:item + tag:-topic_list-item

Any ideas/hints?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.