20,000 posts in one directory

I’m having an issue here for a Hugo site with 20000 or so posts being placed in one folder public/posts/. I’m afraid this is going to be an enormous dir for nginx and Hugo to lookup in.

Are you actually having a problem, or are you simply “afraid” there might be a problem at some point?

I’m afraid that it might cause performance problems in the long run.

I think I should consider nesting after all.

We had this conversation yesterday.
https://discourse.gohugo.io/t/organizing-content-directory-based-on-year-and-month/55896/

yeah, I was just asking people who have sites with tons of posts to see how they managed…

Here’s a project with 25,000 pages in the content/posts directory:
https://github.com/jmooring/hosting-github-pages-25000-pages

Both section and term pages are paginated, so the published site has around 30,000 pages.

The public/posts directory has 55,003 descendant inodes, of which 25,003 are children.

And GitHub Pages serves the site exactly as expected:
https://jmooring.github.io/hosting-github-pages-25000-pages/

I encourage you to test it yourself.

3 Likes

We have setup a folder system and hashing to build new folders for each post (article). There are ways around this, you definetly don’t want over 10,000 files in one folder on a website usually, 10,000 folders would be better.

Great. I’ll test it and come back with my results…

Ok.

Here’s what I did:

I moved every markdown file into a directory of the same name as index.md and put a 1MB image in each(no processing).

Results:

➜  hosting-github-pages-25000-pages git:(main) ✗ hugo
Start building sites … 
hugo v0.150.0+extended+withdeploy darwin/arm64 BuildDate=2025-09-08T13:01:12Z VendorInfo=brew


                  │  EN   
──────────────────┼───────
 Pages            │ 25009 
 Paginator pages  │  4998 
 Non-page files   │ 25003 
 Static files     │     2 
 Processed images │     0 
 Aliases          │     7 
 Cleaned          │     0 

Total in 38598 ms

Compiled on my MacBook M4 Pro. Piece of cake!

Run on a small VPS with 2GB of RAM and 1 vCPU:

WARN  Module "project" is not compatible with this Hugo version: Min 0.150.0 extended; run "hugo mod graph" for more information.
Start building sites … 
hugo v0.148.1-98ba786f2f5dca0866f47ab79f394370bcb77d2f+extended linux/amd64 BuildDate=2025-07-11T12:56:21Z VendorInfo=gohugoio


                  │  EN   
──────────────────┼───────
 Pages            │ 25008 
 Paginator pages  │  4997 
 Non-page files   │     0 
 Static files     │     2 
 Processed images │     0 
 Aliases          │     7 
 Cleaned          │     0 

Total in 37284 ms

Notice I didn’t use images here.