I have a huge site with more than 30 000 posts. When i run hugo command to build the pages the home page is generated first before the rest of posts. But because the site is live and take some time to finish the rest of posts if someone click from the home page to a post return to 404 page. Is there any workaround for this ?
Thank you
I would recommend not deploying your site until it’s finished building
Is there any other way building the site on the actual server?
Yes. There are many ways. Personally I use Netlify.
how can Netlify help in this situation?
I think one workaround may be to use the option: --disableKinds home
to generate all other pages except home at first and then build the home
Because that service does things in a logical order.
What does your current deploy situation look like?
I just have a cronjob running every 20 minutes. The functionality that runs is the bellow
- get some data from some feeds using php.
- php create .md files with the new content inside the content/post directory
- run hugo to build the pages
What happens after/during step 3? That is where your issue is
in the home page are presenting the latest post which they return to 404 page until these latest posts has been generated
That’s not what I asked.
Tell us the steps you’re doing to get your hugo generated static files to your web server.
I don’t understand what you mean. I am new to hugo. These are the steps to generate the static files. I have configure nginx to handle these static assets
No worries that’s okay. Let me ask it differently.
It sounds like you’re running hugo on the same server that serves your site. Is this correct?
yes hugo is running on the production server
I see. Okay here’s what I’d do. Assuming you’re currently serving from public
dir. Render your site to another dir then copy the contents of that dir
hugo --destination foo
cp -R foo/* public
It’s not great. But better than what you’re doing. And should prevent a 404
Thank you very much. I will do this.
One more question: Wouldn’t be better to use rsync instead of cp ?
Possibly. You could test the speed in both
Symlinking would give you atomic deploys without the need to copy files around.
ln -sfn foo public
You’d have to make sure to create a unique foo folder at each build. As a bonus you’d have an easy way to roll back to an earlier build.