Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

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 %}
2 Replies
Message 2 of 3

Re: Accessing repository topics in github pages theme

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!

Copilot Lvl 2
Message 3 of 3

Re: Accessing repository topics in github pages theme

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.