Answers.Body: <pre><code>{% set newsSlug = craft.entries().section('news').select('elements_sites.slug').one().slug ?? null %}
  </code></pre>
  <p><strong>news</strong> - handle your section news;</p>
  <p><strong>select('elements_sites.slug')</strong> - for get only slug your section;</p>
  <p><strong>?? null</strong> - in case if there is no such section;</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-12T18:07:19.590Z
Answers.Text: Thanks, trying this on the section handle "articlesRelatedToArtist" returns "articles-related-to-artist", but the URI format is "artist-news/{slug}", so I actually need the query to return "artist-news"
Answers.UserDisplayName: Matthias
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-03T14:36:44.450Z
Answers.Text: I tried this query on the "news" section with slug 'news' but it returns the slug of the first news article.... I need it to return the 'news' slug, how do I do that?
Answers.UserDisplayName: Matthias
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-12T13:11:03.900Z
Answers.LastActivityDate: 2020-09-12T13:11:03.900Z
Answers.UserDisplayName: Pavel Pavlovich
Body: <p>I want to be able to get the slug of my news section dynamically by searching for its handle.
  Slugs tend to change during the development phase, but the handle doesn't. That's why I want to hard code the news handle in my template to refer to the news section from any other page.</p>
  <p>How to do such a query?</p>
  
Tags: <sections>
Title: Retrieve section slug by handle
ThreadText: # Retrieve section slug by handle
  
  (Asked by: username_0 on 2020-09-11)
  
  I want to be able to get the slug of my news section dynamically by searching for its handle.
  Slugs tend to change during the development phase, but the handle doesn't. That's why I want to hard code the news handle in my template to refer to the news section from any other page.
  
  How to do such a query?
  
  **Tags:** sections
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-09-12. Score: 2
  
  ```
  {% set newsSlug = craft.entries().section('news').select('elements_sites.slug').one().slug ?? null %}
  
  ```
  
  **news** - handle your section news;
  
  **select('elements\_sites.slug')** - for get only slug your section;
  
  **?? null** - in case if there is no such section;
  
  > **Comments:**
  > **username_0**: Thanks, trying this on the section handle "articlesRelatedToArtist" returns "articles-related-to-artist", but the URI format is "artist-news/{slug}", so I actually need the query to return "artist-news"  
  > **username_0**: I tried this query on the "news" section with slug 'news' but it returns the slug of the first news article.... I need it to return the 'news' slug, how do I do that?  
  
  ---
  
  