我正在用HTMLCSS和Javascript制作我的作品集和简单的etch-a-sketch项目。我试图在Heroku上托管网站,但我得到这个错误。
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
这基本上是一个静态网站,我并不真的需要一个buildpack,有什么办法可以让我把我的网站推到Heroku上?
Heroku通常用于部署应用程序,而不是静态网站。我发现使用GitHub页面来托管静态网站要简单得多。如果你的项目已经在GitHub上,只需进入你的repo的设置选项卡,滚动到GitHub页面部分,然后选择你要部署的repo的哪个分支。**编辑 - 确保你的主页html文件的标题是index.html。
但如果你确实因为某种原因需要使用Heroku。这里有一个关于如何做到这一点的指南. 它展示了如何创建静态站点所需的composer.json和index.php。
你可以执行以下步骤
1) 添加一个名为 composer.json
到根目录,运行 touch composer.json
2) 添加一个名为 index.php
到根目录,运行 touch index.php
3) 将主页(如index.html)改名为 home.html
4) 在 index.php
,增加以下一行。<?php include_once("home.html"); ?>
5) 在 composer.json
,添加以下一行。{}
6) 运转 git push heroku master
或
在您的网站目录中运行这些命令
1) $ echo '{}' > composer.json
2) $ echo '<?php include_once("home.html"); ?>' > index.php
3) $ mv index.html home.html
(如果您已经有一个HTML文件名 index
)
谢谢 @wh1tney以下是她的帖子链接。
你可以尝试按照以下步骤进行操作。
index.html
文件到home.html index.php
在根目录下 <?php include_once("home.html"); ?>
composer.json
并在其中写下下面的一行。{} 输入您的Heroku证书。 电子邮件。
<YOUR HEROKU EMAIL>
密码。<YOUR HEROKU PASSWORD>
这里有一个更简单的策略:
在命令提示符下导航到您的项目。
cd Projects/my-site
在终端或命令提示符下登录到heroku。
heroku login
注意:: 不要重新命名 index.html
归档 home.html
. 这将不适合本策略。
创建一个 index.php
文件,并插入这一行代码(<?php header( 'Location: /index.html'
); ?>到它。
echo '<?php header( 'Location: /index.html' ) ; ?>' index.php
将更改添加到git中。
git init
git add .
然后,你要提交或保存所有的变化 为您的网站。用一条信息描述你所做的事情。
git commit -m "my site ready for deployment"
现在你想在Heroku上创建你的网站。如果你已经登录了(因为你运行了 heroku login
之前的),你可以发出以下命令。
heroku apps:create my-static-site
插入你想要的名字,而不是 my-static-site
.
如果没有取名,你可以使用以下方法部署你的网站 git
.
git push heroku master
您现在可以访问您的网站 https://<whatever-name-you-selected>.herokuapp.com/
或我的例子网站在这里 https://my-static-site.herokuapp.com/
.
如果你需要,对你的网站进行以下3个命令的修改。
添加更改....
git add .
保存更改...
git commit -m "add useful message"
然后部署...
git push heroku master
就这些了。
希望对你有帮助