Node.js – Dynamic Links with Jade

expressnode.jspug

Using Jade + Express + Node.js + Mongoose + MongoDB for my app, but this issue I ran into is likely in Jade:

I have some code as follows that prints a list of posts by title, author

div#articles
      -each post in records
         div.article
            #{post.title} was written by #{post.author}
            <a href ="#{post.title}"> Link to Article </a>

Now I want to the link in written Jade instead of HTML, but when I replace the line with

a(href='#{post.title}')

it links to /#{post.title} instead of the variable name such as /newpost1. Doing it as

a(href=#{post.title})

returns an error. I'm sure this is a syntax issue, but I can't find the solution in the GitHub documentation

Best Answer

pretty sure you can just do:

a(href=post.title)