官术网_书友最值得收藏!

Adding partials files for head and footer

Now lets add files for head and footer:

  1. Inside the views/partials folder create a new file called head.html and place the following code:
          <meta charset="utf-8"> 
          <title>{{ title }}</title> 
          <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs
           /twitter-bootstrap/4.0.0-alpha.2/css/bootstrap.min.css'> 
          <link rel="stylesheet" href="/stylesheets/style.css"> 
    
  2. Inside the views/partials folder create a file called footer.html and place the following code:
          <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1
           /jquery.min.js'></script> 
          <script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap
           /4.0.0-alpha.2/js/bootstrap.min.js'></script> 
    
  3. Now, its time to add the partials file to the layout.html page using the include tag. Open layout.html and add the following code:
          <!DOCTYPE html> 
          <html> 
          <head> 
              {% include "../partials/head.html" %} 
          </head> 
          <body> 
               {% block content %} 
               {% endblock %} 
      
              {% include "../partials/footer.html" %} 
          </body> 
          </html> 
    

Finally we are ready to continue with our project. This time our directories structure will look like the following screenshot:

Folder structure

主站蜘蛛池模板: 金溪县| 正阳县| 汉寿县| 永济市| 凌源市| 海晏县| 财经| 乌鲁木齐市| 交口县| 无极县| 九龙城区| 库车县| 剑河县| 东乡县| 西乡县| 桂平市| 绥棱县| 通海县| 余江县| 龙州县| 临清市| 肃南| 辉县市| 慈利县| 康定县| 彭州市| 谢通门县| 兰溪市| 遂平县| 上蔡县| 长葛市| 鹤壁市| 竹山县| 荆州市| 南昌市| 梓潼县| 祁东县| 十堰市| 闽侯县| 铜陵市| 铁力市|