Subpages of Jekyll-powered static site give 404 on app platform?

Posted January 4, 2021 564 views
JekyllDigitalOcean App Platform

I deployed a static Jekyll site on DO App Platform. The site has a number of pages and subpages like /product, /product/product1, /product/product2 etc.

The problem: while the /product page and other top-level pages render great, /product/product1 returns 404 on DigitalOcean app platform, while it works great in local testing.

The permalink is specified like this in product/ YAML front matter:

permalink: "/product/product1"

I should also note that I didn’t use the DO example project to set up the Jekyll project. DO autogenerated everything when I just pointed it to my Jekyll project branch on Github. Everything else seems to work great, just having a problem with some specific subpages.

Is there anything I need to change in my project to get the subpages to render correctly and not return 404?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

👋🏼 @JaanusK

When running bundle exec jekyll build, is /product/product1 generated as product/product1.html?

If that is the case, what’s happening is that when App Platform gets a request for /product/product1, it looks for either a file named exactly product/product1 or product/product1/index.html—none of which exist.

Mapping /product/product1 to /product/product1.html is something that we’re considering however it is not supported yet.

One solution could be to rename the subpages from product/ to product/product1/ This will generate files like /product/product1/index.html which will work with App Platform. Or, you could run a bash script after jekyll build that goes around and relocates subpages to index.html files under subdirectories.

The other option is to deploy the site as a Service instead of a Static Site. I realize this isn’t very ideal but the built-in Jekyll webserver should be able to handle the permalinks properly without making any changes to the source.

Thank you. Your answer put me on the right track, and I got it fixed. You are right, that /product/product1 was generated as /product/product1.html in the site output. The fix for me was to update the permalinks in the metadata of each page so that instead of permalink: "/product/product1", I would have permalink: "/product/product1/" (one slash added). This made them generated as /product/product1/index.html, so that /product/product1 link (with or without the slash) also works now.