Can I Use Data Files?

16 Dec 2022 | ~2 minute read

One of the things I really miss from my days using Jekyll, is the use of data files. Can this be done in WordPress?

So what do I mean by data files? Well, it’s probably best that I use an example.

In Jekyll, I can create a file called blogroll.yml within the _data folder. The contents of blogroll.yml would look something like this:

- name: Andy Bell
  link: https://andy-bell.co.uk/
  rss: https://andy-bell.co.uk/feed

- name: Bradley Taunt
  link: https://bt.ht
  rss: https://bt.ht/atom.xml

- name: Chris Coyer
  link: https://chriscoyier.net
  rss: https://chriscoyier.net/feed

I can then use Jekyll to loop through this data file to produce a pre-formatted blogroll. I’d do that like this:

{{=<% %>=}}<ul>
  {% for item in site.data.blogroll %}
  <li><a target="blank" href="{{ item.link }}">{{ item.name }}</a> (<a href="{{ item.rss }}">RSS feed</a>)</li>
  {% endfor %}
</ul>

Then, when I build my site, Jekyll would loop through the entries in blogroll.yml and would create a list of blogs with completed links that look like this:

Advantages of automation

I love this and I really miss it. It makes producing repetitive content so easy. If I want to add or remove an entry from my blogroll, I just need to edit blogroll.yml and Jekyll does the rest.

However, if I want to add an entry to my blogroll in WordPress, I need to type out the text, highlight the correct bits, then manually add links and add any formatting required. It’s not a massive pain, but there’s no reason for it to be so cumbersome.

BTW, this is just one example. When I was using Jekyll, I used data files for all kinds of things, like navigation, my projects page and an umber of other things. It’s such an elegant solution.

So my question to you WordPress experts is how do I do this in WordPress? I’ve had a look online, but can’t find anything appropriate. I keep getting looped back to guides on importing dummy content for some reason.

As with most things WordPress, there’s probably a very specific term for what I call “data files” that I’m unaware of. There must be a way to do something similar, surely?

If you know how to do this with WordPress, please get in touch using the button below. Any help or advice would be greatly appreciated!

← The one before
What Happens When We’re Gone?

Up next →
The Name of the Wind

Get in touch!

Receiving emails from my readers is my favourite thing, so if you have something to say, feel free to drop me an email or sign my guestbook.

Want more content?

Say no more, dear reader. Here's three random posts from this blog for you to peruse:

Which WordPress Plugins I Use
04 May 2020

Medium Vs Ghost – Which One For a Personal Blog?
08 Jun 2017

Let's Make the IndieWeb Easier
08 Jan 2024

Want to be informed when I post new articles? Simply enter your email address below and you will get an email whenever new posts are published.

Alternatively, you can subscribe via RSS instead.

Enjoyed this post?

I put a lot of work into maintaining this site and I really enjoy interacting with my readers.

My fuel of choice is coffee, so if you did enjoy this post, or found it in any way useful, I'd appreciate more fuel to keep me going. ❤️

Buy me a coffee