Answers.Body: <p>You can use a <a href="https://craftcms.com/docs/4.x/routing.html#dynamic-routes" rel="nofollow noreferrer">custom route</a> for this. While sections only support one default URL for each entry, you can add additional routes related to entries, either through the backend (<em>Settings</em> -&gt; <em>Routes</em>) or in your <code>config/routes.php</code> file.</p>
  <p>Add a route that looks like <code>blog/{slug}/comments</code> through the backend (you can also use the <a href="https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing#named-parameters" rel="nofollow noreferrer">alternative syntax for named parameters</a>, see <a href="https://craftcms.com/docs/4.x/routing.html#advanced-routing-with-url-rules" rel="nofollow noreferrer">advanced routing</a>). Point the route directly to a template, or to a controller that renders the comments template.</p>
  <p>Inside the template (or controller), you need to use an entry query to find the entry that is specified as part of the URL:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set entry = craft.entries()
      .section('blog')
      .slug(slug)
      .one()
  %}
  </code></pre>
  <p>Keep in mind that visitors can enter any slug in the URL that will match the route, so this query may return <code>null</code>. In this case, you want to throw a 404 error to return a 404 response and display the appropriate <a href="https://craftcms.com/docs/4.x/routing.html#error-templates" rel="nofollow noreferrer">error page</a>:</p>
  <pre class="lang-twig prettyprint-override"><code>{% if not entry %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  <p>After this, you have the entry the page belongs to in the <code>entry</code> variable and can display its comments as well as the comment submission form.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-23T11:08:51.773Z
Answers.LastActivityDate: 2023-01-23T11:08:51.773Z
Answers.UserDisplayName: MoritzLost
Body: <p>I really searched this forum for question like this but i was not able to find the answer.</p>
  <p>Im creating news portal website, where I have blog entries with url like this
  <code>/blog/SLUG</code></p>
  <p>I want for every blog article to also have
  <code>/blog/SLUG/comments</code>
  where I will display some info from entry like title, postDate etc
  but instead of regular content a I will display comment form.</p>
  <p>Thanks in advance</p>
  
Tags: <templating><comments>
Title: Create automatic subpage (kind of) for each entry
ThreadText: # Create automatic subpage (kind of) for each entry
  
  (Asked by: username_0 on 2023-01-22)
  
  I really searched this forum for question like this but i was not able to find the answer.
  
  Im creating news portal website, where I have blog entries with url like this
  `/blog/SLUG`
  
  I want for every blog article to also have
  `/blog/SLUG/comments`
  where I will display some info from entry like title, postDate etc
  but instead of regular content a I will display comment form.
  
  Thanks in advance
  
  **Tags:** templating, comments
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-23. Score: 3 | Accepted answer
  
  You can use a [custom route](https://craftcms.com/docs/4.x/routing.html#dynamic-routes) for this. While sections only support one default URL for each entry, you can add additional routes related to entries, either through the backend (*Settings* -> *Routes*) or in your `config/routes.php` file.
  
  Add a route that looks like `blog/{slug}/comments` through the backend (you can also use the [alternative syntax for named parameters](https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing#named-parameters), see [advanced routing](https://craftcms.com/docs/4.x/routing.html#advanced-routing-with-url-rules)). Point the route directly to a template, or to a controller that renders the comments template.
  
  Inside the template (or controller), you need to use an entry query to find the entry that is specified as part of the URL:
  
  ```twig
  {% set entry = craft.entries()
      .section('blog')
      .slug(slug)
      .one()
  %}
  
  ```
  
  Keep in mind that visitors can enter any slug in the URL that will match the route, so this query may return `null`. In this case, you want to throw a 404 error to return a 404 response and display the appropriate [error page](https://craftcms.com/docs/4.x/routing.html#error-templates):
  
  ```twig
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  After this, you have the entry the page belongs to in the `entry` variable and can display its comments as well as the comment submission form.
  
  
  ---
  
  