Any way to compile to a static site on Netlify? #367
-
As the title states, I would like to add yellow to netlify which uses github repository as the source. Netlify copies the source to their servers, compiles to static files, then serves these static files. I have another static cms working there but it is based on GO so the exe just runs to compile. Since Yellow is php I don't know if it's possible to compile without php available on netlify servers? I will look into it a little more. Update - looks like Netlify does support php commands or I could just upload the local compiled static files to github and let Netlify pull those in. Interesting! |
Beta Was this translation helpful? Give feedback.
Replies: 19 comments 1 reply
-
I am afraid to say that I am not a big help with Netlify. Generally, you can generate static files with the command:
This will generate a static website, complete with everything. According to Netlify's documentation PHP 5.6 and PHP 7.2 is supported, Datenstrom Yellow works with both, so you should be able to configure a continuous deployment from GitHub. I am not sure about the details, perhaps you need to adjust the Netlify settings or create a build script. Please contact Netlify support for more information. |
Beta Was this translation helpful? Give feedback.
-
I'll let you know what they say, thanks. |
Beta Was this translation helpful? Give feedback.
-
Just tried on Netlify and it works pretty well. There is something wrong though with the blog links only. The home and about links work, and the blog main page works, just the individual blog links actually show the html code in the browser, not the proper page decoded by the browser. Take a look - https://lley.netlify.com Looks like a mimetype problem. I tried adding to yellow's root folder -
to the .htaccess file but no difference. This is most likely the problem. Firefox respects mimetype I read. Server is sending text/plain instead of text/html. How to change it?? |
Beta Was this translation helpful? Give feedback.
-
Yes you're correct, their web server sends back a Datenstrom Yellow uses clean URLs and that's why some static files have no See also HTTP 1.1, Apache 2.4, MIME type for unknown data Here's what you can do:
Can you please contact Netlify, maybe they can help you with this? |
Beta Was this translation helpful? Give feedback.
-
I have notified Netlify so I'm waiting for their answer. In the meantime is there an edit I can do in the command.php file that adds .html to the end of blog urls? That may be an easy fix, even if it's just for me to use. I don't expect you to modify your code just to make Netlify work but if I know where to edit and make it work it would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
OK, got it working. Had to add this file to my root github repository -
Now all blog posts are rendered as html. |
Beta Was this translation helpful? Give feedback.
-
Thanks Tony, appreciate your feedback. I think this configuration works for your specific website, but as soon as you put pages into other folders it will not work. It would be good if we could find a generic solution, one that can be copy/pasted ...or Netlify's web server would send no default MIME-type. |
Beta Was this translation helpful? Give feedback.
-
Hi there, I work on the tech support team @ Netlify and took a look into this issue. In the case of the URL that was quoted: https://lley.netlify.com - we are actually serving /index.html (as are most web servers, when you request /) so setting a Mime Type of text/html is correct. Could you give me an example of where we are doing it wrong so I can the reproduction steps to our operations team to analyze? |
Beta Was this translation helpful? Give feedback.
-
@fool , OK, I just removed netlify.toml and now you can see the problem if you click into the blog and select any of the three blog posts. Those blog posts are served as text/plain but should be text/html. Just because those blog posts do not have a file extension does not mean they should be served as text/plain as Mark has described above. |
Beta Was this translation helpful? Give feedback.
-
@markseu Just FYI I tried this netlify.toml file -
before the one above I posted a couple of days ago. I thought that it would make all site files a mimetype of text/html. It seemed to work but the strange thing was that the css file for all pages could not be read, ie. all pages had no styling. I don't understand that at all, so that's when I added the blog folder in the path. |
Beta Was this translation helpful? Give feedback.
-
That header rule covers literally every file on your site, so not the best workaround. The one you came up with before was better - covered just the contents of /blog rather than *.css and *.js outside of that directory too. I've got an issue filed on Netlify's infrastructure about that but no timeline on a fix since this is a pretty rare use case. We have a feature called "Pretty URL's" that you're intended to use to be able to serve /file.html with a URL of /file in our asset optimization ; I'd suggest you use that rather than publishing html files as /file in the meantime until we get a fix (when I'll follow up in this thread). |
Beta Was this translation helpful? Give feedback.
-
I tried netlify's prettyurls feature a couple of days ago but it did nothing because it is meant to do the opposite of this problem. It takes a .html file and serves just the filename without .html. You mention this is a rare case, so are you saying that every static file CMS generator deployed on Netlify creates all files with a .html extension and none of them have built-in pretty URLs? If you or one of your techs could do a quick check of the default mimetype on the server my site is deployed on we would know pretty quick what's wrong. |
Beta Was this translation helpful? Give feedback.
-
yes, you'd have to deploy .html files to use it.
…On Tue, Oct 9, 2018 at 11:29 AM tyeeman ***@***.***> wrote:
I tried prettyurls feature a couple of days ago but it did nothing because
it is meant to do the opposite of this problem. It takes a .html file and
serves just the filename without .html.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/datenstrom/yellow/issues/367#issuecomment-428300550>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAN-oKAYSzMIyJaByJa14gT2e2umac2vks5ujOsggaJpZM4W50CZ>
.
|
Beta Was this translation helpful? Give feedback.
-
Unfortunately, we can't use the "Pretty URL" feature to solve this problem. Some static site generators generate files with Here's where I think it goes wrong. If the web server sends a HTTP response for a static file, it usually detects the MIME type based on the file extension. There are different MIME types that a web server needs to know, a typical website consists of HTML, CSS, font and image files. If the web server doesn't know the MIME type of a file, for example a file without extension, then there a different ways to proceed. One is to send a HTTP response without In a nutshell, if the web server doesn't send a "default MIME type" it works out of the box. As a workaround for Netlify, you can try the following. Change the default MIME type to |
Beta Was this translation helpful? Give feedback.
-
Yes, your bug report was quite clear and I have filed a corresponding bug
on our side.
Since this thread is the only place any of our >300k customers has noticed
the problem, it is a very low priority bug, so I was informing you of the
workaround that would work today.
I have no ETA on the fix for the bug on our side since it is quite
complicated (involving 3 separate services) and since we have many higher
priority issues, so I thought I'd leave you with some suggestion so you
could deploy a site today.
…On Wed, Oct 10, 2018 at 12:44 AM Mark Seuffert ***@***.***> wrote:
Unfortunately, we can't use the "Pretty URL" feature to solve this problem.
Some static site generators generate files with html extension and you
need an extra step to rewrite the URL into something pretty. We decided to
do this different. Datenstrom Yellow generates files for clean URLs
<https://en.wikipedia.org/wiki/Clean_URL> right away. I am sorry to say,
this behaviour can't be changed.
Here's where I think it goes wrong. If the web server sends a HTTP
response for a static file, it usually detects the MIME type based on the
file extension. There are different MIME types that a web server needs to
know, a typical website consists of HTML, CSS, font and image files. If the
web server doesn't know the MIME type of a file, for example a file without
extension, then there a different ways to proceed. One is to send a HTTP
response without Content-Type header, another is to send a Content-Type
header with a default MIME type. The first gives the web browser a chance
to detect the correct media type, this is what the Apache web server does.
Netlify's web server doesn't do this, it sends a default MIME type for
files it doesn't know.
The HTTP protocol says the following in section 3.1.1.5.
<https://tools.ietf.org/html/rfc7231#section-3.1.1.5>:
A sender that generates a message containing a payload body SHOULD
generate a Content-Type header field in that message unless the
intended media type of the enclosed representation is unknown to the
sender.
In a nutshell, if the web server doesn't send a "default MIME type" it
works out of the box. As a workaround for Netlify, you can try the
following. Change the default MIME type to text/html or configure
text/html for locations that don't start with /media/. Hope this helps.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/datenstrom/yellow/issues/367#issuecomment-428471562>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAN-oOlbTH3UNVpfsD4qSCiOJ4OaZdy4ks5ujaV2gaJpZM4W50CZ>
.
|
Beta Was this translation helpful? Give feedback.
-
Thanks Chris, appreciate your suggestions. @tyeeman I would use the first
|
Beta Was this translation helpful? Give feedback.
-
I just noticed that Yellow is now on staticgen.com with a deploy to netlify button! One of us should try it and see if it actually works. I wonder if they have changed something at their end due to this issue? |
Beta Was this translation helpful? Give feedback.
-
Just loaded Yellow up to my normal web host and I got a similar problem when accessing blog posts. Instead of viewing html code, I got a window asking if I wanted to download the file! So I asked my web host to determine why and he came back with this .htaccess file, which works good -
So, if netlify has an equivalent to this .htaccess file, I'll be set. I sent them an email. |
Beta Was this translation helpful? Give feedback.
-
They got back to me and it looks like they don't have anything that will do this. |
Beta Was this translation helpful? Give feedback.
I am afraid to say that I am not a big help with Netlify.
Generally, you can generate static files with the command:
php yellow.php generate
This will generate a static website, complete with everything. According to Netlify's documentation PHP 5.6 and PHP 7.2 is supported, Datenstrom Yellow works with both, so you should be able to configure a continuous deployment from GitHub. I am not sure about the details, perhaps you need to adjust the Netlify settings or create a build script. Please contact Netlify support for more information.