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

  • Node.js 6.x Blueprints
  • Fernando Monteiro
  • 107字
  • 2021-07-14 10:35:05

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

主站蜘蛛池模板: 茌平县| 甘孜县| 普陀区| 土默特右旗| 饶阳县| 庄浪县| 惠安县| 西乡县| 石嘴山市| 北流市| 喀喇| 池州市| 天柱县| 孟连| 石城县| 措勤县| 新疆| 大连市| 新余市| 四川省| 六盘水市| 昌宁县| 德保县| 苏尼特左旗| 曲沃县| 泌阳县| 盐亭县| 天柱县| 偏关县| 滦平县| 淮滨县| 永平县| 迁西县| 通许县| 建始县| 永丰县| 嘉祥县| 两当县| 岳阳县| 蓝山县| 临泉县|