Custom 404 page - existing plugins?

It seems that you need to develop a plugin to customize the 404 page.

Does anyone have an example of a plug-in that does that?

We’d love to (radically) change the 404 page, would be a shame if we’d develop a plugin if other have done so before :slight_smile:

6 Likes

Bump! I’d like to hide some of the existing widgets and show a New Topic button.

I see that the 404 page title can be set via Settings > Customize > Text Content > [search for current 404 error text that is displayed] but more options would be nice!

1 Like

Hello,

I am looking to personalize my 404 page due to the IPB to Discourse migration.
I would like to have a simple page with text.

What is the best option?

Thank you

1 Like

Has anyone figured this out? The 404 template is handled by ruby, not by JS, which is weird.
Is there a way to make custom 404 hbs template and style it through theme?

1 Like

I’m also looking for a way to customize the 404 page. One problem I’m having is that some sections of a forum are private. So when I link to it in chat or from another post, and the users aren’t logged in to the forum, it looks to them like I linked to a page that doesn’t exist. Users don’t like to think too much in general, so I think that many of them don’t pay attention to the “or is private” part of the “Oops! That page doesn’t exist or is private” message, because it looks like the page doesn’t exist.

What I would like to do is: if not logged in, and the page is a 404, then show the sign-up or log in form on top of the 404 page (without redirecting, since that might confuse search engines). If the user is logged in and they don’t have access, then the regular 404 page would be shown.

Does anyone know if there is a way to do that?

Enable the enhanced but secrecy leaking 404 page in your site settings.

Is the page supposed to look different? I just tried that on two sites, and I still what looks like the same error page:

I rebuilt the forum on one of them to be sure it wasn’t just a caching problem, and tried for private topics and for pages that weren’t found.

My settings look like this:

2 Likes

Which “sections” are you linking to? Are you linking to a specific topic?

1 Like

Yes, I’ve tried loading specific topics, posts, categories, and non-existent pages while not logged in, and I see that same page.

1 Like

Let’s see. Here is a topic on my self-hosted Discourse in the Staff category:

https://discourse.codinghorror.com/t/test-topic-for-close-states/3516

When I load it with detailed 404 set to false (the default), I see

Oops! That page doesn’t exist or is private.

Which is what I would expect. However, when I change detailed 404 to true, I see the same thing… did we regress here @sam or am I misunderstanding the feature? :thinking:

I even did a rebuild just in case but same result. I think I’d expect to see

Sorry, you don’t have access to this topic

with detailed 404 enabled?

4 Likes

I think the message you see is correct because staff ultimately is a private category, but I can be Wrong.

No, the idea is that you intentionally leak information in this case with detailed 404, the topic does exist, but you can’t access it for some reason.

3 Likes

I think @dan worked on this feature, maybe Dan you have some ideas about what is going on?

3 Likes

Detailed #404 error messages are displayed only if the user can do something to see the group, usually by joining a group (joining freely or by sending a membership request).

In this case, the users cannot join or send membership requests for the @staff group, which explains why the detailed error page is not shown. I think of adding an “else” case when “detailed 404” is enabled which would display

Oops! That page is private.

instead of

Oops! That page doesn’t exist or is private.

6 Likes

Yes the else clause is preferable here.

2 Likes

Also consider adding a “Go back” button (window.history.back()) to the Ember version of the 404 page, as that’s the only sensible action people can take in this case.

2 Likes

That has been implemented. Turns out that the server already returned 403, it was just the error message.

https://github.com/discourse/discourse/pull/9894

3 Likes

Excellent, I updated my self-hosted instance and now the staff topic

https://discourse.codinghorror.com/t/test-topic-for-close-states/3516

Correctly returns

Oops! That page is private.

With detailed 404 enabled, when visited in incognito mode. Thank you! :clap:

4 Likes

One request we frequently get is for that page to show a login button in such a case, since logging in could make the topic accessible.

5 Likes

I think that is a fantastic and sensible request. @eviltrout can you perhaps assign that if it is not too risky before the release?

6 Likes