Tucker McKnight
Change the clone part to a before, instead of after, hook The buildSteps part still needs to happen in an after hook (throws an error about the repository not existing otherwise), but we can clone the repo and put it in the _site directory before the site generation happens. This also seems to fix a race condition that was happening with buildSteps, which was sometimes throwing an error about the repo not existing when it was trying to do the build steps. I'm assuming that's because somehow the buildSteps were running before the repo was done cloning. A side effect of this is that the repo can be cloned and available in your public HTML folder even if the site generation fails. So people can be pulling commits from the repo that are not mentioned in the HTML pages. This might actually be a good thing -- users might want their code to be available, even if the site isn't up-to-date.
63
"eleventy.after",
63
"eleventy.before",
87
87
const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
await exec(`git -C ${location} symbolic-ref HEAD refs/heads/${repoConfig.defaultBranch}`)
}
}
)
eleventyConfig.on(
"eleventy.after",
async ({ directories }) => {
for (let repoName in reposConfiguration.repos) {
const repoConfig = reposConfiguration.repos[repoName]
106 107 108 109
const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
await exec(`git -C ${location} symbolic-ref HEAD refs/heads/${repoConfig.defaultBranch}`)
);
106 107 108 109
)
6
6
## Brainstorming Jan 10, 2026
- Where to do this?
- Currently, repo is clone in `main.ts` in an `eleventyConfig.on("eleventy.after")` callback
- There is also an `eleventyConfig.on("eleventy.before")` that you can use