Adding Syndication Urls to My Posts
Tags: indieweb, hugo
Published: 2020-07-01 00:49:43

---
title: Adding Syndication Urls to My Posts
published: true
date: 2020-06-30 19:31:16 UTC
tags: indieweb, hugo
canonical_url: https://anaulin.org/blog/adding-syndication-urls/
---

Inspired by this weekend’s [IndieWebCamp West](https://indieweb.org/2020/West), I added support to record and display syndication urls for my posts on this site.

The indieweb<sup id="fnref:1"><a href="#fn:1" role="doc-noteref">1</a></sup> community encourages posting your content to your own site, and then liberally sharing either copies or links elsewhere on the web. The idea is that you own your content, and you can also give it wider distribution via social media or news aggregrators. They call this [POSSE](https://indieweb.org/POSSE) (Publish on your Own Site, Syndicate Elsewhere). Once you share your content “off-site”, it is helpful to visitors if you indicate on the original post where else tt can be found.

I don’t provide a way to comment on my site, but I do share some posts on social media and in other places that are more conducive to conversation. I thought it would be nice to point visitors at those other places where you can find the content and maybe even interact with me.

To capture the URLs, I decided to use a new field in my posts’ frontmatter, named `syndication_urls` and shaped as a list of strings. Each string in the list represents an alternate URL at which the post is syndicated. The metadata for an example post with syndication URLs looks like:

```
+++
title = "Pomodoro Technique as Self-Awareness Tool"
date = 2018-11-01T16:57:52-07:00
tags = ["working better"]
syndication_urls = ["https://dev.to/anaulin/pomodoro-technique-as-self-awareness-tool-2n0k", "https://twitter.com/anaulin/status/1058147565647134721?s=20"]
+++

[...post content...]

```

In the templates that generate the HTML for a post, I display these links like so:

```
{{ if .Params.syndication_urls }}
  <div class="syndication">
      <i class="fas fa-link"></i>
      This post was also syndicated to:
      {{- range $index, $url := .Params.syndication_urls }}
        {{- $parsed_url := urls.Parse $url -}}
        {{- if $index }}, {{- end }}
        <a class="u-syndication" href="{{ $url }}" rel="syndication">{{ $parsed_url.Host }}</a>
      {{- end }}
    </small>
  </div>
{{ end }}

```

It’s somewhat ugly, as [Hugo](https://gohugo.io/)‘s Golang-based templates tend to be. But it is simple and it works! As a bonus, it includes the requisite [microformats](http://microformats.org/wiki/rel-syndication) to indicate that these are syndication urls.

Once the post has been rendered, the links looks something like this:

![](https://anaulin.org/img/syndication-urls.jpg)

I’m pretty happy with it.

An unexpected bonus is that now I will have a structured way to collect this data, which might come in handy in the future. A future enhancement I’d like to add is replacing the plain text link with nice icons for some well known sites, like Mastodon or Twitter.

<section role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p>I don’t love the term <em>indieweb</em>, but I’ll use it for lack of a better one. To me, indieweb is just, well, web. The ideas of owning your own data and making your own site (and having fun with it!) existed well before someone invented this term. The prefix <em>indie</em>, in particular, feels like trying too hard to say “hey, i’m the small guy, i’m the good guy”. I guess folks wanted to be very clear that this is not Facebook or Medium or some other Big Tech Vortex of Doom, dammit. Fair enough. You can read more about this indieweb business on the <a href="https://indieweb.org/">IndieWeb wiki</a>. Naming quibbles aside, there are good ideas in there. <a href="#fnref:1" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</section>

---

_This post was originally published on https://anaulin.org/blog._