这是一个相当老的问题,但我在为类似问题寻找自己的解决方案时发现了OPs帖子。 // this link should take me to the 'new post' page which is rendered only from an ejs template (no HTML) and has a matching endpoint on my express router obj as 'new' <a href="new" class="new-post-link">new post</a> // clicking this link would move the user to the /new endpoint and would render the 'new post' page upon clicking the link <a href="new" class="new-post-link">new post</a> // for OP's specific problem: // original <button id="loginBtn"> <a href="views/login.ejs"><LI> LOGIN </LI></a> </button> // solution <button id="loginBtn"> <a href="login"><LI> LOGIN </LI></a> </button>我希望它能帮助某人。