What *do* I commit to git?

Hello kind folk!

I finally decided to version control my blog, now that I have a tiny self hosted forgejo instance.

While right now, all I want is version control so that I can pull my files down wherever I want.
I might want to play with automatically deploying it via actions too at some later date.

So, with all this in mind, what files do I commit to the repo?This is my current tree. Does all of it, go in?

.
├── archetypes
├── assets
├── config
├── content
├── data
├── i18n
├── layouts
├── resources
├── static
└── themes

Thank you :slight_smile:

In general you only have to commit the folders where you have self created files.

If a folder is empty no need to commit.

Special handling:

  • archetypes
    Only needed when you use hugo new content

  • resources:
    Usually generated at build. If you don’t want to optimize with caching fe. when doenloading external ressources or expensive operations. You dont need it

.
├── archetypes
├── assets
├── config
├── content
├── data
├── i18n
├── layouts
├── resources
├── static
└── themes
1 Like

A .gitignore file in the root of your project, which you do commit, typically looks something like this:

.hugo_build.lock
node_modules/
public/
resources/

If you have already committed some of these files:

git rm -rf .hugo_build.lock node_modules/ public/ resources/
git add -A
git commit -m "Remove extraneous files from source control"

One possible exception to this is the resources directory which, by default, contains some of the cached build artifacts: processed images and stylesheets. If you use a CI deployment workflow (e.g., Cloudflare Pages, GitHub Pages, GitLab Pages, Netlify), builds can be significantly faster if you include this directory in source control.

4 Likes

@irkode, @jmooring thank you both!
will do as you advise. (archetypes, I do have a couple so that goes in)

@jmooring, thank you for always putting so much thought and care into your advice.
will also create a .gitignore so that stuff I want out, stays out.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.