Hosting static HTML pages generated by Jekyll or any other static site generator with pretty permalinks (the one’s without .html) on to S3 would yield into a 404. The reason is that S3 is an object store hence it doesn’t really look up for a .html version of a page’s permalink.
The solution is copying the file to S3 without the .html extension and explicitly setting the content type of the file, for example:
1
|
|
By this S3 would send the file contents along with the content-type header set to text/html
. To scale, I use the below script which automates this:
1 2 3 4 5 6 |
|
Here’s what it does:
- Push all the files to S3 excluding all .html files
- Iterate all the
.html
files and push them to S3 without the extension and with content-type