Skip to content

Improve 404 page #1347

Open
Open
@adamchainz

Description

@adamchainz

Take a broken docs link like: https://docs.djangoproject.com/en/4.2/ref/databasess/ (two "s" chars at the end instead of one).

The 404 page could at least show the docs search bar to make it easy to search for the relevant page.

For bonus points, it could even show search results for the keywords in the URL ("databasess") or show close matches from existing URL's (using e.g. difflib.get_close_matches).

Activity

gautam8404

gautam8404 commented on Apr 28, 2023

@gautam8404

like this?

image

however i don't thinks what i did is a proper way of doing it, i used same search as in documentation page by making some changes in templatetags/docs.py

def search_form(context):
    request = context["request"]
    version = context["version"] if "version" in context else context["DJANGO_VERSION"]
    lang = context["lang"] if "lang" in context else context["LANGUAGE_CODE"]
    release = DocumentRelease.objects.get_by_version_and_lang(
        version,
        lang,
    )
    return {
        "form": DocSearchForm(request.GET, release=release),
        "version": version,
        "lang": lang,
    }

and in 404.html

{% extends 'base_error.html' %}
{% load docs %}

{% block title %}Page not found{% endblock %}
{% block header-classes %}
container--flex container--flex--wrap--mobile
{% endblock %}
{% block header %}
  <h1>404</h1>

  {% search_form %}

{% endblock %}

{% block content %}
<h2>Page not found</h2>

<p>Looks like you followed a bad link. If you think it's our fault, please <a href="https://code.djangoproject.com/">let us know</a>.</p>

<p>Here's a link to the <a href="{% url 'homepage' %}">homepage</a>. You know, just in case.</p>

{% endblock %}

A more proper way would be writing a handler for 404? but maybe i should ask permission for it before

Om15102003

Om15102003 commented on Dec 6, 2023

@Om15102003

@adamchainz I would like to contribute on this issue.

added a commit that references this issue on Dec 20, 2023
9b27b40
SurajSanap

SurajSanap commented on Dec 20, 2023

@SurajSanap

fixed by #1454

bengali-creates

bengali-creates commented on Dec 11, 2024

@bengali-creates

hi i ma new to this project i want to contribute in this project for this problem . Can anyone pls tell me how can i get in contact with the devs

bmispelon

bmispelon commented on Dec 11, 2024

@bmispelon
Member

hi i ma new to this project i want to contribute in this project for this problem . Can anyone pls tell me how can i get in contact with the devs

Hi and thanks for offering to contribute! 🎸

The file is there: https://github.com/django/djangoproject.com/blob/main/djangoproject/templates/404.html

For reference, I found it using this command: git ls-files '**/404.html'

bengali-creates

bengali-creates commented on Dec 25, 2024

@bengali-creates

hi i ma new to this project i want to contribute in this project for this problem . Can anyone pls tell me how can i get in contact with the devs

Hi and thanks for offering to contribute! 🎸

The file is there: https://github.com/django/djangoproject.com/blob/main/djangoproject/templates/404.html

For reference, I found it using this command: git ls-files '**/404.html'

Hi and thanks for your time.

i was setting up the environment by using docker but faced the same error though i followed the documentation .
If I could get the solution it would be great help
Screenshot 2024-12-25 211813

added a commit that references this issue on Dec 28, 2024
ShivangKeshri

ShivangKeshri commented on Jan 9, 2025

@ShivangKeshri

Hi! I would love to contribute to this project! Is this issue still prevalent?

pauloxnet

pauloxnet commented on Feb 4, 2025

@pauloxnet
Member

I realize only now that we have a fundamental UX problem that could be blocking.

I believe that the 404 template is used for all 404 errors both on the site (https://www.djangoproject.com) and in the documentation (https://docs.djangoproject.com).

The search is only present in the documentation subdomain, so whoever were to view the 404 page in the domain (https://www.djangoproject.com) would see a search that is actually from the domain (https://docs.djangoproject.com).

The solutions proposed so far therefore I do not think are mergiable.

I see two alternatives:

  1. have a specific 404 template page to be shown in the domain (https://docs.djangoproject.com) with the search and leaving that of the domain (https://www.djangoproject.com)
  2. implement a site-wide search as in this issue Site-wide search #1499
ShivangKeshri

ShivangKeshri commented on Feb 4, 2025

@ShivangKeshri

Cool, I will try out the first alternative.

AhmedNassar7

AhmedNassar7 commented on Feb 8, 2025

@AhmedNassar7

Hi! 👋 I'd love to contribute to this issue. Based on the discussion, it seems like a separate 404 template for the documentation site would be a good approach. I'll share updates soon.

cyphase

cyphase commented on May 25, 2025

@cyphase

Is anyone currently working on this?

adamchainz

adamchainz commented on May 29, 2025

@adamchainz
SponsorMemberAuthor

I would guess not!

cyphase

cyphase commented on May 29, 2025

@cyphase

Your comment prompted me to look here again, and now I see that there's an open PR with recent activity. #1923

Seems like it's just waiting for review. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @bmispelon@pauloxnet@adamchainz@cyphase@sabderemane

      Issue actions

        Improve 404 page · Issue #1347 · django/djangoproject.com