将 public 添加到 .gitignore 后,Netlify 无法部署站点 [英] Netlify fails to deploy site after public is added to .gitignore

查看:72
本文介绍了将 public 添加到 .gitignore 后,Netlify 无法部署站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

I am now reading that I can add my public/ folder to .gitignore, as Hugo should build it on a remote server:

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

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/了.我所做的就是这个.

So, I tried that. I made sure GitHub isn't tracking public/ anymore. What I've done is this.

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

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"

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

This removed my public/ folder from GitHub (https://github.com/taraskaduk/taraskaduk), as expected.

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

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

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

现在,这是部署日志:

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?

按照下面的建议,我添加了一个构建命令和 Hugo 版本.现在部署没有失败,Netlify 说站点是活动的,但 URL 上没有任何内容

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

推荐答案

在评论中提出了解决方案(至少部分):I was missing a hugo deploy command

The solution (at least partial) was suggested in the comments: I was missing a hugo deploy command

这篇关于将 public 添加到 .gitignore 后,Netlify 无法部署站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆