Add a nav bar to all templates

后端 未结 3 2030
执笔经年
执笔经年 2021-02-13 14:20

I want to show a nav bar on every page. In PHP, I would write the nav bar then include it on the other pages. I tried to include or extend the nav bar template into the other

3条回答
  •  不知归路
    2021-02-13 14:37

    You can include the nav bar in every page.

    nav.html

    
    
    
    NAVBAR

    layout.html: note the {% include 'nav.html' %}

    
    
        
        {% include 'nav.html' %}
    
        {% block content %}
        {% endblock %}
        
    
    

    index.html

    {% extends "layout.html" %}
    
    {% block content %}
        

    This is the homepage!

    {% endblock %}

    sometimes, it is a good way to design you web page. You break you page to, for example: head.html, nav.html, footer.html... you can include them in the layout.html to use them.

提交回复
热议问题