Html file template for Django

I understand if this quetion isn't phrased correctly, but i trying because i cant find the answer.


Hello, i have a quetion(sorry if its a simple quetion, i`m beginner in django). I want to create a template html file so that it copy each time. I understand that a block exists and can be modified through it, but I want to create a template that can be inserted in the right place in the HTML code, and edit the template as needed.

Exampl what it looks like now :

<!doctype html>
<html lang="en">

<head>
  <title>TITLE</title>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS v5.2.0-beta1 -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css"
    integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">

</head>
    <body>
        <!--NAWBAR-->
        <nav class="navbar navbar-expand-lg bg-light">
            <div class="container-fluid">
                <b class="navbar-brand" href="#">Tezla</b>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="{% url 'home' %}">Home</a>
                    </li>
                    <li class="nav-item">
                    <a class="nav-link" href="{% url 'blog:all_blogs' %}">Blog</a>
                    </li>
                    <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        Dropdown
                    </a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="#">Action</a></li>
                        <li><a class="dropdown-item" href="#">Another action</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="#">Something else here</a></li>
                    </ul>
                    </li>
                    <li class="nav-item">
                    <a class="nav-link disabled">Disabled</a>
                    </li>
                </ul>
                <form class="d-flex" role="search">
                    <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                    <button class="btn btn-outline-success" type="submit">Search</button>
                </form>
                </div>
            </div>
        </nav>       
        <header>
 
            <!--NAME PAGE-->
            <h1>NAME PAGE</h1>
        </header>
        <main>
           
            

        </main> 
        <footer style='text-align:right'>
        <!-- place footer here -->
            <a href="">my instagram</a>
        </footer>
    </body>
</html>

What I want it to look like :

<!doctype html>
<html lang="en">

<head>
  <title>TITLE</title>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS v5.2.0-beta1 -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css"
    integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">

</head>
    <body>

        <!--NAWBAR-->
        ??Some function??
        <header>
 
            <!--NAME PAGE-->
            <h1>NAME PAGE</h1>
        </header>
        <main>
           
            

        </main> 
        <footer style='text-align:right'>
        <!-- place footer here -->
            <a href="">my instagram</a>
        </footer>
    </body>
</html>

And copy in needed seats, and edit if needed.

I'm sorry if the question is too simple

I found the answer to my question in the django documentation.

Here - https://docs.djangoproject.com/en/4.1/ref/templates/builtins/#include

Back to Top