In this article, I will show you how you can generate trackback requests to external websites to link back to your static site like Jekyll or Hugo. I decided to write this article after realizing how there is almost no information online about how to make DIY trackback requests when I was trying to set it up.

What is Trackback?

From Wikipedia:

A trackback allows one website to notify another about an update. It is one of four types of linkback methods for website authors to request notification when somebody links to one of their documents. This enables authors to keep track of who is linking to their articles. Some weblog software, such as SilverStripe, WordPress, Drupal, and Movable Type, supports automatic pingbacks where all the links in a published article can be pinged when the article is published. The term is used colloquially for any kind of linkback.

Essentially, it is a mechanism for other websites to know that you mentioned them, with the hope that they’ll notice you and possibly mention you as well. It helps to increase the visibility and discoverability of your website.

Use Case

My use case was to send trackbacks to arXiv, so that specific arXiv papers will know that my blog post mentioned them, and readers can also check it out as an additional resource. In particular, each of my paper summary posts is based around a paper, and it would be nice if they could be linked from the respective arXiv paper abstract pages.

In arXiv, there is a blog link section that will track websites that made trackback requests for a given paper:

Unfortunately, if you try to search for anything about trackbacks and/or pingbacks, most of what you’ll get are articles about how to disable them on popular blogging platforms like WordPress due to widespread misuse and spam, or otherwise how to configure them.

There was also a 7-year old StackOverflow post about how to create trackback requests for arXiv, essentially the same problem I was facing. Sadly, it currently has a grand total of 0 answers and 0 comments. I hope this article might be useful if the author is still facing the issue.

Manually Creating Trackback Requests

The convenience of CMS blogging software like WordPress is that it supports features like automated trackbacks and pingbacks for content that you create. Static site generators are not capable of this, since by design they are static and stateless. This means that we have to make such requests manually, which is fortunately not too difficult!

Here’s a very simple script for doing it. In this example, the target URL is for the arXiv trackback endpoint.

Before reading or running the code, please note that you SHOULD NOT test or experiment on this with trackback listener URLs and spam them. You should only make requests if they are legitimate and you have a genuine reason for letting them know about your blog post. Trackback spam is a serious issue and part of why they have become so unpopular and unmanageable is due to the high volumes of spam.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import requests

# Replace with your own data
data = {
    'title': 'My Awesome Blog Post',
    'url': 'https://my-blog.com/post/',
    'blog_name': 'My Awesome Blog'
}

# Replace with actual Trackback destination URL
trackback_url = f'https://foo.bar/trackback/post_id'

response = requests.post(trackback_url, data=data)

if response.status_code == 200:
    print("Trackback successful!")
else:
    print(f"Trackback failed with status code: {response.status_code}")

print(response.content.decode())

A successful response has the error field set to 0:

<?xml version="1.0" encoding="utf-8"?>
<response>
  <error>0</error>
</response>

If an error occured, the error field is set to 1:

<?xml version="1.0" encoding="utf-8"?>
<response>
  <error>1</error>
  <message>(some error message)</message>
</response>

Conclusion

And that’s all there is to creating Trackback requests! It’s actually quite simple, and is just not terribly well-documented.

As a final parting word, a reminder again to please use it responsibly and stay away from any behavior that could be constituted as spamming.