How Repositories Are Sorted and Displayed on the Generated Resume
Repositories on the generated resume are sorted by a popularity score calculated as the sum of watchers (stars) and forks, with only the top five non-forked repositories displayed using a Mustache template.
The resume/resume.github.com project automatically generates visual resumes from GitHub profiles. When you enter a username, the application fetches public repository data and applies a specific algorithm to determine which projects appear on the resume and in what order.
The Popularity Scoring Algorithm
The sorting logic centers on a simple popularity metric that combines social signals from the GitHub API.
Calculating Repository Popularity
In js/githubresume.js, each repository receives a popularity score computed as the arithmetic sum of its watchers (stars) and forks:
popularity = repo.watchers + repo.forks;
This calculation occurs immediately after fetching repository data from the GitHub API. The resulting value determines the repository's relative importance compared to other projects owned by the user.
Filtering and Sorting Logic
Before sorting occurs, the application filters out specific repository types to ensure only original work appears on the resume.
Excluding Forked Repositories
The algorithm explicitly ignores forked repositories. During the data collection phase in js/githubresume.js, the code checks the fork boolean property returned by the GitHub API:
// Only non-forked repositories are added to the sorted array
if (!repo.fork) {
sorted.push(repo);
}
This ensures that the generated resume highlights original contributions rather than copies of other projects.
Descending Sort by Popularity
After collecting all non-forked repositories into the sorted array, the application applies a comparator function that orders repositories from highest to lowest popularity:
function sortByPopularity(a, b) {
return b.popularity - a.popularity;
}
sorted.sort(sortByPopularity);
This descending sort ensures that the most socially validated projects (those with the highest combined star and fork counts) appear first in the final output.
Display Limits and Rendering
The sorting algorithm directly impacts which repositories users see, but the display layer imposes additional constraints.
The Five-Repository Cap
The resume displays a maximum of five repositories, controlled by the maxItems variable defined near the top of js/githubresume.js:
var maxItems = 5;
During the rendering loop, the code checks this limit before processing each repository:
if (itemCount >= maxItems) { return; }
This means even if a user owns dozens of popular repositories, only the top five by popularity score appear on the generated resume.
Mustache Template Integration
For each of the top five repositories, the application constructs a view object containing metadata extracted from the GitHub API:
view = {
name: repo.info.name,
date: date,
language: repo.info.language,
description: repo.info.description,
homepage: repo.info.homepage,
username: username,
watchers: repo.info.watchers,
forks: repo.info.forks,
watchersLabel: repo.info.watchers == 0 || repo.info.watchers > 1 ? 'stars' : 'star',
forksLabel: repo.info.forks == 0 || repo.info.forks > 1 ? 'forks' : 'fork',
};
This view object merges with the views/job.html Mustache template, and the resulting HTML appends to the #jobs container in the main resume layout:
html = Mustache.to_html(template, view);
$('#jobs').append($(html));
Customizing the Sorting Behavior
Developers can modify the sorting logic by adjusting variables in js/githubresume.js.
Changing the Display Limit
To show more than five repositories, modify the maxItems variable or accept a query parameter:
var maxItems = parseInt(urlParams.max) || 5;
This allows URLs like ?user=octocat&max=10 to display ten repositories instead of five.
Weighting Stars Higher Than Forks
To prioritize stars over forks in the popularity calculation, adjust the scoring formula:
popularity = (repo.watchers * 2) + repo.forks;
This modification counts each star as twice the value of a fork, altering the final sort order to favor repositories with high star counts even if they have fewer forks.
Summary
- Popularity scoring combines watchers (stars) and forks into a single numeric value in
js/githubresume.js. - Fork filtering ensures only original repositories enter the sorting pipeline.
- Descending sort orders repositories from highest to lowest popularity score.
- Five-repository limit restricts the display to the top five projects by popularity.
- Mustache templating renders each selected repository using
views/job.htmland injects it into the#jobscontainer.
Frequently Asked Questions
How does the resume determine which repositories appear first?
The resume calculates a popularity score for each non-forked repository by adding its watcher (star) count and fork count. Repositories sort in descending order by this score, meaning projects with the highest combined social signals appear at the top of the generated resume.
Why do some of my repositories not appear on the resume?
The application filters out forked repositories entirely, showing only original work. Additionally, the resume displays a maximum of five repositories controlled by the maxItems variable in js/githubresume.js. If you own more than five non-forked repositories, only the most popular five (by stars plus forks) render on the page.
Can I change how many repositories display on my resume?
Yes, you can modify the maxItems variable in js/githubresume.js to increase or decrease the limit. The default value is 5, but changing this to 10 or another number alters how many repositories appear in the final output. You could also implement URL parameter parsing to allow dynamic limits via query strings like ?max=10.
Is it possible to sort repositories by a different metric than popularity?
While the default implementation uses the sum of watchers and forks, you can customize the sorting logic by modifying the popularity calculation in js/githubresume.js. For example, you could weight stars more heavily than forks, sort by creation date, or use the GitHub API's pushed_at field to prioritize recently active repositories. The sortByPopularity comparator function controls the final ordering.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →