i using gulp-file-include build html pages using partials & templates. using context variables, can customize each meta headers. however, don't know how include line only if context variable exists, "@@else" statement doesn't seem exist.
my parent html looks like:
@@include ('_header.html', { "title":"my page", "description": "description", "canonical":"http://www.sourcefromquote.com" }) <body> wonderful page @@include ('_footer.html") </body></html> i thinking use _header.html close :
<html> <head> <title>@@title</title> <meta name="description" content="@@description"> @@if (canonical) { <link rel="canonical" href="@@canonical" /> } </head> if "canonical" variable not set in the parent html, throws error (canonical not defined).
i guess include full tag in variable , forget @@if, not clean expected !
any ideas ? thank in advance.
in head, enter:
@@if (context.canonical) {<link rel="canonical" href="@@canonical" />} in file includes header enter:
@@include('_head.html', { "canonical" : "https://www.website.com/canonical-link.html" })
Comments
Post a Comment