Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
usando un diseño común para todas las páginas en pug

Estoy probando pug con express

 views/layout.pug doctype html html head title= title link(rel="shortcut icon", href="favicon.ico", type="image/x-icon") link(rel='stylesheet', href='/assets/application.css') link(rel='stylesheet', href="assets/libs/bootstrap/dist/css/bootstrap.min.css") body script(src="assets/libs/jquery/dist/jquery.min.js") script(src='assets/libs/bootstrap/dist/js/bootstrap.min.js') script(src="assets/application.js") block content

Este es el enrutador para la página de usuario.

 routes/user.js var express = require('express'); var router = express.Router(); /* GET users listing. */ router.get('/', function(req, res, next) { res.render('user/index'); }); module.exports = router;

Tengo mi vista para la página de usuario/índice. Extiendo el diseño de las vistas. Página de índice de usuario usando el diseño. layout.pug está presente en la carpeta de vistas.

Si agrego un layout.pug dentro de vistas/usuario, funciona. Pero cómo usar las vistas/layout.pug

 /views/user/index.pug extends layout block content h1 | User index

Obtuve el siguiente error. está buscando el diseño en la carpeta de vista/usuario. Cómo hacer que use view/layout.pug.

 Error: ENOENT: no such file or directory, open 'C:\my_projects\myexpressapp\views\user\layout.pug' at C:\my_projects\myexpressapp\views\user\index.pug line 1 at Error (native) at Object.fs.openSync (fs.js:640:18) at Object.fs.readFileSync (fs.js:508:33) at Function.read (C:\my_projects\myexpressapp\node_modules\pug-load\index.js:69:13) at Object.read (C:\my_projects\myexpressapp\node_modules\pug\lib\index.js:147:25) at C:\my_projects\myexpressapp\node_modules\pug-load\index.js:24:25 at walkAST (C:\my_projects\myexpressapp\node_modules\pug-walk\index.js:23:18) at C:\my_projects\myexpressapp\node_modules\pug-walk\index.js:104:20 at Array.reduce (native) at walkAndMergeNodes (C:\my_projects\myexpressapp\node_modules\pug-walk\index.js:103:18)
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

En su archivo app.js , verifique si ha definido las vistas correctamente.

El motor de vista debe configurarse en pug y la carpeta de vistas debe configurarse correctamente como se describe a continuación en app.js

 app.set('view engine', 'pug'); app.set('views', path.join(__dirname, 'views'));
about 4 years ago · Santiago Trujillo Report

0

Tienes que configurar la variable baseDirectory .

No estoy familiarizado con Express, encontré la respuesta ¿Cómo se configura la opción jade basedir en una aplicación express? (se requiere la opción "basedir" para usar "extensiones" con rutas "absolutas")

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!