Accessing repository topics in github pages theme

Is it possible to retrieve the topics for a repository in a theme?

I would like to list all repositories which have a certain topic, but I haven’t been able to find a way to this. Is anyone aware of a method of doing this? Otherwise it might be a nice feature to add.

An example of what it might look like:

{% for repository in site.github.public_repositories %}
{% if repository.topics contains "production_ready" %}
      <a href="{{ }}">{{ }}</a> (<a href="{{ repository.html_url }}">repo</a>) </br>
   {% endif %}
{% endfor %}
1 Like

Something like this would most likely need to be a Jekyll plugin. You could search the list of GitHub repositories that have the jekyll-plugin topic perhaps? I didn’t find anything pre-made that seemed to fit what you’re going after, but perhaps there is something pre-made that will get you started?

I hope that helps!

I found an alternative method using the repository description rather than topics, but thanks for the suggestion!

Here is what I’m doing in case anyone is interested :

I’m adding “Category:<label>” at the end of the description and then using this to create arrays of repo names:

{% assign productionReady = '' | split: '' %}
{% assign experimental = '' | split: '' %}

{% for repository in site.github.public_repositories %}
  {% assign category = repository.description | split: "Category:" | last %}
  {% assign repoName = | split: '@@@' %}
    {% if category == "Production-Ready" %}
      {% assign productionReady = productionReady | concat: repoName %}
    {% endif %}
    {% if category == "Experimental" %}
      {% assign experimental = experimental | concat: repoName %}
    {% endif %}
{% endfor %}

Then looping over these arrays I can make links.

1 Like

I’d love to have topics available in the Repository Metadata. I assume the reason it’s not in there is because of the following disclaimer in the API documentation:

Note: The topics property for repositories on GitHub is currently available for developers to preview. To view the topics property in calls that return repository results, you must provide a custom media type in the Accept header:


It would be neat if we could opt-in to preview features like this with something like preview: true in _config.yml.

If you have a feature that you’d like to suggest for Jekyll, which is how you would get a change to how the _config.yml behaves, you can file a feature request on the Jekyll project on GitHub.

I hope that helps!

Since this feature is only relevant for GitHub Pages, I don’t think Jekyll is the correct recipient of such a feature request. A github node in _config.yml could probably be used to contain GitHub Pages related configuration.

repository.topics was made available in github-metadata version 2.13.0 by the following pull request.