Reputation: 1378
I'm trying to follow the suggestions in the Blogdown book. For a while, I was building my blogdown site locally and then letting Netlify deploy it.
I am now reading that I can add my public/
folder to .gitignore
, as Hugo should build it on a remote server:
The public/ directory should be ignored if your website is to going to be automatically (re)built on a remote server such as Netlify.
So, I tried that. I made sure GitHub isn't tracking public/ anymore. What I've done is this.
First, I added public
to my .gitignore
Then, I had this git commit
git rm -r --cached .
git add .
git commit -am "Remove ignored files"
This removed my public/
folder from GitHub (https://github.com/taraskaduk/taraskaduk), as expected.
On Netlify, my deploy fails. First, here are my deploy settings (I feel like I should change something here, but I"m not seeing any instructions to do so):
Repository: https://github.com/taraskaduk/taraskaduk
Build command: Not set
Publish directory: public
Production branch: master
Branch deploys: Deploy only the production branch and its deploy previews
Public deploy logs: Logs are public
(I tried messing with publish directory and build command, but without instructions, it's a waste of time as I'm not sure what I'm doing)
Now, here is the deploy log:
5:18:42 PM: Build ready to start
5:18:44 PM: Fetching cached dependencies
5:18:44 PM: Starting to download cache of 131.5MB
5:18:45 PM: Finished downloading cache in 1.239616218s
5:18:45 PM: Starting to extract cache
5:18:46 PM: Finished extracting cache in 1.126354925s
5:18:46 PM: Finished fetching cache in 2.450276606s
5:18:46 PM: Starting to prepare the repo for build
5:18:47 PM: Preparing Git Reference refs/heads/master
5:18:47 PM: No build command found, continuing to publishing
5:18:47 PM: Failing build: Failed to build site
5:18:47 PM: failed during stage 'building site': Deploy directory 'public' does not exist
5:18:48 PM: Finished processing build request in 4.119821718s
I guess what I'm not clear on is why is it looking for the public directory if it was supposed to be re-built?
I guess something is not clicking for me... I'm sure my error is rather stupid and elementary. Help?
EDIT: Following the suggestion below, I added a build command and hugo version. Now the deploy doesn't fail, Netlify says the site is live, but there is nothing at the URL
Upvotes: 2
Views: 2584
Reputation: 14353
Once you have your .gitignore
working correctly, adding a netlify.toml
to your site projects will help assure the correct build commands get ran with the version you are targeting for your deploy contexts also.
# Global settings applied to the whole site.
[build]
command = "hugo"
publish = "public"
# Build a preview of the site (Drafts and Future dates also)
# Un-comment next two lines.
#[context.deploy-preview]
# command = "hugo --buildFuture"
[context.production.environment]
HUGO_VERSION = "0.41"
# you can lock a version of hugo for a deploy preview
[context.deploy-preview.environment]
HUGO_VERSION = "0.41"
# you can lock a version of hugo for a branch-deploy (other than previews)
[context.branch-deploy.environment]
HUGO_VERSION = "0.41"
This will allow more control over your builds.
Note: More information here also
Upvotes: 1
Reputation: 1378
The solution (at least partial) was suggested in the comments: I was missing a hugo
deploy command
Upvotes: 1