Answers.Body: <p>Do you mean</p>
  
  <pre><code>{% set section = craft.sections.getSectionByHandle(craft.request.getSegment(1)) %}
  {{ section.name }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-21T14:08:52.240Z
Answers.LastActivityDate: 2018-02-21T14:08:52.240Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I'd like to retrieve the name of a section based on a url segment. Normally I would use {{entry.section.name}}, but this doesn't work, since there is no entry available.</p>
  
  <p>I've got this working:</p>
  
  <pre><code>{% set entry = craft.entries.section(craft.request.getSegment(1)).first %}
  
  &lt;h2&gt;{{entry.section.name}}&lt;/h2&gt;
  </code></pre>
  
  <p>This means that I first have to get an entry and then reverse retrieve the section it belongs to.</p>
  
  <p>Is there no direct way to get the section name based on a url?</p>
  
Tags: <url><sections>
Title: Get the section name based on a url segment
ThreadText: # Get the section name based on a url segment
  
  (Asked by: username_0 on 2018-02-21)
  
  I'd like to retrieve the name of a section based on a url segment. Normally I would use {{entry.section.name}}, but this doesn't work, since there is no entry available.
  
  I've got this working:
  
  ```
  {% set entry = craft.entries.section(craft.request.getSegment(1)).first %}
  
  <h2>{{entry.section.name}}</h2>
  
  ```
  
  This means that I first have to get an entry and then reverse retrieve the section it belongs to.
  
  Is there no direct way to get the section name based on a url?
  
  **Tags:** url, sections
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-02-21. Score: 3 | Accepted answer
  
  Do you mean
  
  ```
  {% set section = craft.sections.getSectionByHandle(craft.request.getSegment(1)) %}
  {{ section.name }}
  
  ```
  
  
  ---
  
  