简体   繁体   中英

an error in pug(jade) not show content from layout

hi guys I'm recently start pug(jade) and i cant load my layout

here its my layout.pug

html(lang='en')
 head
  title hi
  link(rel='stylesheet', type='text/css', href='../public/css/W3.css')     

  link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Allerta+Stencil')  
body
 div.w3-bar.w3-black
  div.w3-left.w3-margin-left
   a.w3-bar-item.w3-opacity.w3-large.w3-btn(href='#') My website template                     
   a.w3-bar-item.w3-button.w3-hover-green(href='#') Home            
   a.w3-bar-item.w3-button.w3-hover-green(href='#') Link 1
  div.w3-right.w3-margin-right
   a.w3-bar-item.w3-button.w3-hover-blue(href='#') Link 2                     
   a.w3-bar-item.w3-button.w3-hover-orange(href='#') Link          
div.w3-margin.w3-continer.w3-center
 div.w3-margin.w3-card-4.w3-continer
  p.w3-jumbo.w3-opacity(class='.w3-allerta') this is my first template                 
  p.w3-large.w3-margin welcome to Home

and i load it with index.pug

extends layout
block content
 h3 hello world

which i load that with this code

  app.get('/', function (req, res) {
  res.render('index.pug');
  });

also i put my css framework w3.css in public folder with this code

 app.use(express.static(path.join(__dirname, "public")))

and i get this error

Error: C:\Users\MashadService.ir\Desktop\node js\express-simple-website\views\index.pug:3:1

 Unexpected block content
  at makeError (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-error\index.js:32:13)
  at error (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-linker\index.js:7:30)
  at C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-linker\index.js:47:9
  at Array.forEach (<anonymous>)
  at link (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-linker\index.js:45:20)
  at compileBody (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:170:9)
  at Object.exports.compile (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:242:16)
  at handleTemplateCache (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:215:25)
  at Object.exports.renderFile (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:427:10)
  at Object.exports.renderFile (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:417:21)

thank you for helping me

layout.pug in add code block content

html(lang='en')
 head
  title hi
  link(rel='stylesheet', type='text/css', href='../public/css/W3.css')     

  link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Allerta+Stencil')  
body
 div.w3-bar.w3-black
  div.w3-left.w3-margin-left
   a.w3-bar-item.w3-opacity.w3-large.w3-btn(href='#') My website template                     
   a.w3-bar-item.w3-button.w3-hover-green(href='#') Home            
   a.w3-bar-item.w3-button.w3-hover-green(href='#') Link 1
  div.w3-right.w3-margin-right
   a.w3-bar-item.w3-button.w3-hover-blue(href='#') Link 2                     
   a.w3-bar-item.w3-button.w3-hover-orange(href='#') Link          
div.w3-margin.w3-continer.w3-center
 div.w3-margin.w3-card-4.w3-continer
  p.w3-jumbo.w3-opacity(class='.w3-allerta') this is my first template                 
  p.w3-large.w3-margin welcome to Home

  block content

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM