How do I create a custom theme to show location data?

:wave: Hello!

What you have to do is:

  1. Create a custom theme.

  2. Update the template layouts/post/single.html to include your location information.

How you want to present the location information in step 2 is up to you. Manton shared this snippet as a starting point:

{{ if .Params.location_latitude }}
  <img src="https://example-mapping-service.com/?center={{ .Params.location_latitude }},{{ .Params.location_longitude}}" />
{{ end }}

So, for example, if you want to link to your location on a map, you could do something like this:

{{ if .Params.location_latitude }}
  <a href="http://maps.apple.com/?ll={{ .Params.location_latitude }},{{ .Params.location_longitude}}&z=4">🗺 See this location on a map</a>
{{ end }}

You could also take a peek behind the curtain on others’ implementations, like this plug-in or this theme.

2 Likes