title: How can I get the base url with Flask / Jinja2?
body: <p>I have a <code>base.html</code> template which I would like to use for all pages. This <code>base.html</code> contains a navigation</p>
  
  <pre><code>&lt;nav&gt;
    &lt;li&gt;&lt;a href="./home"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="./foo"&gt;bar&lt;/a&gt;&lt;/li&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>This is no problem when I'm on the same level (e.g. <code>localhost:5000/whatever</code>), but when I'm in a subfolder (e.g. <code>localhost:5000/whatever/insert</code>) the links break.</p>
  
  <p>This can be fixed by making the relative links absolute, e.g.</p>
  
  <pre><code>&lt;nav&gt;
    &lt;li&gt;&lt;a href="{{base_url}}/home"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="{{base_url}}/foo"&gt;bar&lt;/a&gt;&lt;/li&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>However, I don't know how to get the <code>base_url</code>. If possible, I would like to avoid adding <code>base_url</code> to each <code>render_template</code> call. And, if possible, I would also like to avoid to set <code>base_url</code> manually.</p>
  
  <p>How is this problem solved with Flask / Jinja2?</p>