title: Sorted Map Iteration in Go Templates?
body: <p>I'm building a website in Go, using the <a href="http://gohugo.io/" rel="nofollow">Hugo static site generator</a>. What I'm trying to do is build a dynamic navigation bar for my web pages.</p>
  
  <p>Here's what I'm doing:</p>
  
  <p>In my <code>config.yml</code> file, I've defined a Map of links that I'd like to appear in my navbar -- here's what this file looks like:</p>
  
  <pre><code>baseurl: "https://www.rdegges.com/"
  languageCode: "en-us"
  title: "Randall Degges"
  params:
    navLinks: {"Twitter": "https://twitter.com/rdegges", "Facebook": "https://www.facebook.com/rdegges", "Google+": "https://plus.google.com/109157194342162880262", "Github": "https://github.com/rdegges"}
  </code></pre>
  
  <p>So, I've also got an <code>index.html</code> template in Hugo that contains a navbar which looks like this:</p>
  
  <pre><code>&lt;nav&gt;
    &lt;ul&gt;
      {{ range sort $title, $link := .Site.Params.navLinks }}
        &lt;li&gt;&lt;a href="{{ $link }}"&gt;{{ $title }}&lt;/a&gt;&lt;/li&gt;
      {{ end }}
    &lt;/ul&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>This above code works correctly, with one exception: I'd like to order the results of my links instead of having them randomly ordered each time.</p>
  
  <p>I know that Maps are not inherently structured in Go -- but is there a way to retain the original ordering of my navigation elements in some way?</p>
  
  <p>Thanks for the help!</p>