DEV Community

Ema Suriano
Ema Suriano

Posted on • Originally published at emasuriano.com on

Get Github repository preview images

While I was writing another TIL I needed to put some image about an open source project, in this case, was the popular project of Ollama. Normally what I do is take a screenshot of the website and store it locally in my assets folder, which is what most of the websites also do.

The main issue of this problem is not the fact that the repository size is going to grow (I solved this issue by using Git submodules), it is that the image most probably is going to get out of date. The information about the post is most probably also going to get outdated, but having as well old pictures doesn't help a lot ...

While I was searching for some kind of image that represents the project without information that can get outdated, I found this preview:

Ollama Github preview

It caught my attention because all the information was extremely up-to-date, considering that the last commit was less than 12 hours ago.

Then I decided to inspect the URL and, I found out that, it was coming from the Open Graph of Github assets. The URL itself looks like:

https://opengraph.githubassets.com/16dc0ce438cf338ca03e98e84238f23161d058f1665111075ba68fcd2f0ecf04/ollama/ollama

Enter fullscreen mode Exit fullscreen mode

Then I checked on the Internet what each part means, and I found the following explanation:

https://opengraph.githubassets.com/<random_hash>/<owner>/<repo>

Enter fullscreen mode Exit fullscreen mode

After knowing this I started playing with some of my other repositories and I found that I can always reliably get an up-to-date Github preview of my projects. As an example, I generated the one for this website:

Portfolio Github preview

That will be all for now.

Thanks for reading.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay