Answers.Body: <p>Instead of using one separate query for each page, use just one query to get all pages and then iterate through them:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set pages = craft.entries()
      .section(['page1', 'page2', 'page3'])
      .all();
  %}
  
  &lt;ol&gt;
      {% for page in pages %}
          &lt;li&gt;&lt;a href=&quot;{{ page.getUrl() }}&quot;&gt;{{ page.title }}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
  &lt;/ol&gt;
  </code></pre>
  <p>(Sidenote: You'll want to use <code>ul</code> or <code>ol</code> for lists so your HTML has a better semantic structure).</p>
  <p>You can control the order of the query with the <a href="https://craftcms.com/docs/3.x/entries.html#orderby" rel="nofollow noreferrer"><code>orderBy</code> parameter</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-22T10:04:10.560Z
Answers.Text: Thank you so much, exactly what I was looking for.
Answers.UserDisplayName: Samuel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-22T08:53:15.737Z
Answers.LastActivityDate: 2022-02-22T08:53:15.737Z
Answers.UserDisplayName: MoritzLost
Body: <p>I was wondering if there is a more efficient way, performance side, to call multiple urls for a navigation element in case of a multi language site (so static links are not an option).</p>
  <pre><code>&lt;div&gt;
    &lt;span&gt;&lt;a href=&quot;{{ craft.entries.section(&quot;page1&quot;).one().url }}&quot;&gt;Page 1&lt;/a&gt;&lt;/span&gt;
    &lt;span&gt;&lt;a href=&quot;{{ craft.entries.section(&quot;page2&quot;).one().url }}&quot;&gt;Page 2&lt;/a&gt;&lt;/span&gt;
    &lt;span&gt;&lt;a href=&quot;{{ craft.entries.section(&quot;page3&quot;).one().url }}&quot;&gt;Page 3&lt;/a&gt;&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  <p>The code above is generating alone 7 new queries, why 7?</p>
  
Tags: <navigation><performance><queries>
Title: Multiple entries urls performance
ThreadText: # Multiple entries urls performance
  
  (Asked by: username_0 on 2022-02-21)
  
  I was wondering if there is a more efficient way, performance side, to call multiple urls for a navigation element in case of a multi language site (so static links are not an option).
  
  ```
  <div>
    <span><a href="{{ craft.entries.section("page1").one().url }}">Page 1</a></span>
    <span><a href="{{ craft.entries.section("page2").one().url }}">Page 2</a></span>
    <span><a href="{{ craft.entries.section("page3").one().url }}">Page 3</a></span>
  </div>
  
  ```
  
  The code above is generating alone 7 new queries, why 7?
  
  **Tags:** navigation, performance, queries
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-02-22. Score: 0 | Accepted answer
  
  Instead of using one separate query for each page, use just one query to get all pages and then iterate through them:
  
  ```twig
  {% set pages = craft.entries()
      .section(['page1', 'page2', 'page3'])
      .all();
  %}
  
  <ol>
      {% for page in pages %}
          <li><a href="{{ page.getUrl() }}">{{ page.title }}</a></li>
      {% endfor %}
  </ol>
  
  ```
  
  (Sidenote: You'll want to use `ul` or `ol` for lists so your HTML has a better semantic structure).
  
  You can control the order of the query with the [`orderBy` parameter](https://craftcms.com/docs/3.x/entries.html#orderby).
  
  > **Comments:**
  > **username_0**: Thank you so much, exactly what I was looking for.  
  
  ---
  
  