How to order site params by source order?

Maps are always sorted by key when iterating with a range loop:
https://discourse.gohugo.io/t/38500/2

I would restructure the data:

params:
  socials:
    - icon: fab fa-github
      name: GitHub
      url: 'https://github.com/yourname'
      weight: 1
    - icon: fa fa-envelope
      name: E-mail
      url: 'mailto:yourname@gmail.com'
      weight: 2

Then sort by weight:

{{ range (sort site.Params.socials "weight") }}
  <a href="{{ .url }}" title="{{ .name }}" rel="noopener" target="_blank"><i class="{{ .icon }}"></i>{{ .name }}</a>
{{ end }}

You can use the index function.

1 Like