Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Include way to handle 404 pages #60

Closed
arenowebdev opened this issue Jul 5, 2016 · 8 comments
Closed

[Proposal] Include way to handle 404 pages #60

arenowebdev opened this issue Jul 5, 2016 · 8 comments

Comments

@arenowebdev
Copy link

Not sure if I'm just overlooking the section in the documentation or through my trials through the code, but would be cool to handle missing pages with a 404.blade.php file or something when those errors occur.

Was thinking along the lines of how Laravel uses the errors folder for those views, though not entirely certain how to implement it yet at this point.

@adamwathan
Copy link
Contributor

adamwathan commented Jul 5, 2016

Hey David! I wish this was that easy, but since it's a static site it has to be handled at the webserver level. If you use GitHub Pages, you can just create a 404.html file in your root and it will work automatically, otherwise have to configure it in the webserver, and point whatever errors you want to whatever error pages 👍

For anyone else who finds this issue down the road, here's an example of how you might do it with nginx: https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-to-use-custom-error-pages-on-ubuntu-14-04

@arenowebdev
Copy link
Author

Duh. Was way over thinking this one. Thanks!

@chrisvidal
Copy link

chrisvidal commented Aug 30, 2017

Hi i tried ot crate a 404.html in the source folder, but it is not copy over during the build process. Any idea on how to copy this file ?
thanks

EDIT: found it, pipe this line in your gulpfile.js

    .copy( elixir.config.publicPath + '/404.html', 'build_github/404.html')

EDIT:
in the end, it does not copy anything :(

@adamwathan
Copy link
Contributor

I think that's probably an issue of pretty URLs being enabled by default so your file is ending up at /build_github/404/index.html

Might be a way to disable that per page if you're clever 🤔

@damiani
Copy link
Contributor

damiani commented Aug 30, 2017

@chrisvidal Make sure that .copy line in your gulpfile falls after the .exec line, or else the file that gulp just copied will get deleted at the .exec step. Otherwise, using .copy as you have it should work.

One thing you might change is to append a _ before the filename in source, if you don't need end up with a 404/index.html file in build_github:

.copy( elixir.config.publicPath + '/_404.html', 'build_github/404.html')

@chrisvidal
Copy link

chrisvidal commented Aug 30, 2017

thank @damiani
yes I did this, but the file is not copied neither

whenI follow manually the content of the folder build_github/ I can see the 404.html first then it is removed.
and I have this

    .exec('jigsaw build', ['./source/**/*', '!./source/_assets/**/*'])
    .copy( elixir.config.publicPath + '/_404.html', 'build_github/404.html')

Is it because my command line is like this ?

gulp && jigsaw build github

@damiani
Copy link
Contributor

damiani commented Aug 30, 2017

Another way you can do it, if you have pretty URLs enabled, is to name your source file 404.html.blade.php. Jigsaw will process it as a normal Blade file (allowing you to use a parent template, for example, just like with any Jigsaw file) and output it to build_github/404.html/index.html, which will be accessible in the browser at 404.html.

@chrisvidal
Copy link

chrisvidal commented Aug 30, 2017

Interesting idea, I am using github pages, let's see if it can support this
EDIT: not working for github pages.

Well i guess i will have to forget the idea of handling the 404 error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants