Search code examples
jekyllnext.jsgithub-pages

js and css not loading when hosting next application on GitHub pages


Next.js builds all the static assets in _next folder but Github pages does not need to serve those files. I am 404 for static assets.

Example repo: https://github.com/ajaymathur/ajaymathur.github.io Master branch is hosted and dev branch is for development.

And I guess github pages is not hosting paths starting with -. How can I get around this issue?


Solution

  • Add a .nojekyll file in the root of your pages repo.

    This disables Jekyll processing and lets the _next folder (which contains an underscore) get copied to the final website.