Is it possible to aggregate posts from multiple Jekyll sites?

I haven’t been able to track down any documentation or forum discussions that cover this topic, so hoping someone here can help.

Let’s say I have a Jekyll site deployed at MYSITE.COM with a standard blog page listing all of my posts in the _posts directory. Then let’s say I spin up two new subdomains of the site at SUBDOMAIN1.MYSITE.COM and SUBDOMAIN2.MYSITE.COM, and each of these sites has its own standard blog page listing posts in their own _posts directories. How would I go about aggregating the blogs from the original domain and the two subdomains into one list on the blog page of the original domain?

To deploy a subdomain, in my experience this requires a separate repository that is then directed to the subdomain URL in your DNS, rendering the subdomain a functionally distinct website from the base domain. Given this, I suppose my question is effectively the same as asking how to aggregate posts from three distinct sites, each of which I control. Am I correct in thinking Jekyll can’t do this out of the box? Does anyone have any experience doing something like this with javascript, or another solution?

Note: I am comfortable using collections and categories to have multiple different blogs and sets of pages on a single site; this topic is specifically to see how I would go about collecting multiple sites’ posts on one other site, assuming I have repository access to each of the sites I want to aggregate.

I’ve seen some stuff before about linking repos - or somehow combining them but I don’t know how to do it. At one point I am fairly sure someone had separated out their posts into one repo and the theme and other stuff into another and was somehow able to pull in the other repo. So technically there may be a way to do something like that - google something about git and multiple repos.

Another idea would be to have the subdomains also publish a json file of all their post data and then use JS on the main site to pull that in - but I am not sure you would be able to actually combine them. Though I suppose you could do the same thing on the main site and then use JS to display all the posts.

Seems a little hacky but doable.

Jekyll is not going to handle this out of the box though maybe with the git option above it could do it and not know anything was going on?

I think this is what I had seen:

you’d have to be careful to keep the repos in sync.

Aha, submodules! Okay yes, that makes sense, I think that would have to be the way to go. OP in the linked post is effectively doing what I want to do.

Like you point out, and like in the linked post, keeping the parent repo and submodule(s) in sync would be the key piece, but doing a quick search online seems to indicate that it’s possible to automate that… will look into it.

Many thanks for pointing me in the right direction!

(Looks like this could be a solution for that automation: gitlab - Is there any automatic way to update the parent git repo to point to the latest commit of its submodule? - Stack Overflow)

There is a way to do what you need using git branches locally, each branch using a different upstream repository for deployment.

  • one branch is site A
  • the second branch is site B
  • site N is it’s own third branch, from which you run git merge branch-name-A and git merge branch-name-B before pushing it to it’s own repo