public 添加到 .gitignore 后,Netlify 无法部署站点

Netlify fails to deploy site after public is added to .gitignore

我正在尝试遵循 Blogdown 书中的建议。有一段时间,我在本地构建我的 blogdown 站点,然后让 Netlify 部署它。

我现在读到我可以将我的 public/ 文件夹添加到 .gitignore,因为 Hugo 应该在远程服务器上构建它:

The public/ directory should be ignored if your website is to going to be automatically (re)built on a remote server such as Netlify.

所以,我试过了。我确保 GitHub 不再跟踪 public/。 我所做的就是这个。

首先,我将 public 添加到我的 .gitignore 然后,我有这个 git commit

git rm -r --cached .
git add .
git commit -am "Remove ignored files"

如预期的那样,这从 GitHub (https://github.com/taraskaduk/taraskaduk) 中删除了我的 public/ 文件夹。

在 Netlify 上,我的部署失败了。 首先,这是我的 部署设置 (我觉得我应该在这里更改一些内容,但我没有看到任何这样做的说明):

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

(我试过弄乱发布目录和构建命令,但没有说明,这是浪费时间,因为我不确定自己在做什么)

现在,部署日志

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

我想我不清楚的是,如果它应该被重建,为什么要寻找 public 目录?

我猜有些东西不适合我...我确定我的错误相当愚蠢和初级。帮助?


编辑: 按照下面的建议,我添加了一个构建命令和 hugo 版本。现在部署没有失败,Netlify 说该站点是实时的,但是 URL

上什么也没有

评论中建议了解决方案(至少部分):我缺少 hugo 部署命令

一旦您的 .gitignore 正常工作,将 netlify.toml 添加到您的站点项目将有助于确保正确的构建命令获得 运行 您的部署目标版本上下文也。

# 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"

这样可以更好地控制您的构建。

注: