r语言 - 将 public 添加到 .gitignore 后,Netlify 无法部署站点



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

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

如果您的网站要在远程服务器(如Netlify(上自动(重新(构建,则应忽略public/目录。

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

首先,我在.gitignore中添加了public然后,我有这个 git 提交

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

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

我想有些东西没有为我点击...我敢肯定我的错误是相当愚蠢和基本的。帮助?


编辑: 按照下面的建议,我添加了一个构建命令和 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"

这将允许对构建进行更多控制。

注意:更多信息也在这里

相关内容

最新更新