简体   繁体   English

Unable to deploy static website to heroku, html and css not loading from php

[英]Unable to deploy static website to heroku, html and css not loading from php

So I am trying to deploy static website to heroku but the main page isn't loading the html/css files.所以我试图将 static 网站部署到 heroku 但主页没有加载 html/css 文件。

Link to app: https://randomstockpicker.herokuapp.com/应用链接: https://randomstockpicker.herokuapp.com/

when I looked at the source code it shows:当我查看源代码时,它显示:

<?php include_once("home.html"); ?>

this php code isn't loading the "home.html" file, the file exists and is uploaded as well.此 php 代码未加载“home.html”文件,该文件存在并且也已上传。

I also got composer.json: {}我也得到了 composer.json: {}

I followed this tutorial: https://medium.com/@agavitalis/how-to-deploy-a-simple-static-html-website-on-heroku-492697238e48我按照本教程进行操作: https://medium.com/@agavitalis/how-to-deploy-a-simple-static-html-website-on-heroku-492697238e48

Instead of using:而不是使用:

<?php include_once("home.html"); ?>

this worked perfectly这工作得很好

<?php include_once("./home.html"); ?>

The tutorial you followed asks you to rename the index.html file to a custom one (home.html), and uses a PHP file (which is a server-side scripting language) to "load" the static file.您遵循的教程要求您将 index.html 文件重命名为自定义文件 (home.html),并使用 PHP 文件(这是一种服务器端脚本语言)来“加载”ZA81259CEF8E959C6247EDF1 文件。

It's not rendering the page because Heroku isn't configured to serve PHP files.它没有呈现页面,因为 Heroku 未配置为提供 PHP 文件。

I recommend you mv home.html index.html (renaming you homepage back to index.html, which is a standard file that browsers look for) and you should see your static site. I recommend you mv home.html index.html (renaming you homepage back to index.html, which is a standard file that browsers look for) and you should see your static site.

Just as a side-note, PHP is not static, it's a dynamic scripting language, so if you're aiming at building a static site, avoid anything else than HTML + JS + CSS. Just as a side-note, PHP is not static, it's a dynamic scripting language, so if you're aiming at building a static site, avoid anything else than HTML + JS + CSS.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM