We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Is there a way to prevent Publii from overwriting the 404.html file?

  • #1579
    Avatar photo[anonymous]

    I modified the 404 page from my theme to include custom text, CSS classes, and a JavaScript back button. Every time I render a preview of my website, it writes over my 404.html and I have to resave it from my code editor. Is there a way to stop Publii from doing this?

    Avatar photo[anonymous]

    A possible solution could be:

    • customize your 404 file (provided by Publii) and rename it like:   404-page.html  or something like this.
    • declare your default error page via htaccess:

    ErrorDocument 404 /404-page.html

    it should work

    Avatar photo[anonymous]

    Hi @andriezzo,

    Thanks for that. I have a tendency to ignore certain things, for instance the fact that I was editing the Preview render file. Of course, in Input there isn’t a 404.html file. Does .htaccess go in the root of my Input folder?

    Avatar photoBob

    Hi, the 404.html file can be found in the following location: ‎⁨(Documents ▸ ⁨Publii⁩ ▸ ⁨sites⁩ ▸ ⁨YOUR_SITE ▸ ⁨input⁩ ▸ ⁨themes⁩ ▸ ⁨YOUR_THEME)

    Avatar photo[anonymous]
    [anonymous] wrote:

    Hi @andriezzo,

    Does .htaccess go in the root of my Input folder?

    Yes, it must be in the root folder but it works on an Apache server.

    Avatar photo[anonymous]

    Great. Thanks all for your replies. I do appreciate it!