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

  • 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

主站蜘蛛池模板: 布尔津县| 崇左市| 临江市| 岱山县| 延边| 广州市| 泰兴市| 东港市| 玉门市| 孝感市| 灵石县| 甘洛县| 苍山县| 克山县| 九龙县| 台南县| 恩施市| 西宁市| 大丰市| 裕民县| 四平市| 开封市| 西乡县| 讷河市| 文安县| 济阳县| 紫金县| 板桥市| 安吉县| 灵山县| 大城县| 鄂伦春自治旗| 昭觉县| 江安县| 淳化县| 甘孜县| 东平县| 平顶山市| 吉首市| 阿拉善左旗| 南京市|