Change the clone part to a before, instead of after, hook

3820b5156f4ff5313be541b5b0e1192d252bee54

Tucker McKnight | Sun Jan 11 2026

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.
main.ts:63
Before
63
    "eleventy.after",
After
63
    "eleventy.before",
main.ts:87
Before
87
After
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]
main.ts:106
Before
106
107
108
109

        const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
        await exec(`git -C ${location} symbolic-ref HEAD refs/heads/${repoConfig.defaultBranch}`)
  );
After
106
107
108
109
  )
wiki/projects/clone-early.md:6
Before
6
After
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