@craigz Thank you for sharing the repo! It helps tremendously. I found the source of trouble for your project:
That’s the tricky part of Pug, white spacing controls structuring:
div.View.WelcomeView
h1.Banner WHATABYTE
The Banner element gets pushed down because it’s a sibling of the WelcomeView element. If you indent it, it becomes its child
At that point in the tutorial, the index.pug template should look like this:
extends layout
block layout-content
div.View.WelcomeView
h1.Banner WHATABYTE
div.Message
div.Title
h3 Making the Best
h1 Food For Devs
span.Details Access the WHATABYTE Team Portal
div.NavButtons
if isAuthenticated
a(href="/user")
div.NavButton Just dive in!
else
a(href="/login")
div.NavButton Log in
so much closer now. the parent-child relationship now appears to work correctly and the image loads in the way i would expect. the only remaining issue is that the entire page remains pushed down an entire page of whitespace. so the initial page load is all white and unless you know to scroll down a page, it appears there is nothing there. i had entirely focused on the css as that is entirely unknown to me, i’d not even thought about what pug was doing there. i’ll focus on that a bit more and see how it goes. i’ll update here if i manage to work things out, otherwise if you have any other ideas as to why the whitespace, let me know. i’ve updated the repo with the changes to index.pug.
Hi dan, how are you doing?
I’m using express 4.17.1. I followed the post but got a problem on app.use(express.static(...)). Basically it didn’t middlewared anything at all. I went to documentation and saw that it used relative path instead of path.join(base, public). I removed the path.join thing and it worked fine.
The question is, you said to use path.join to have a env independent file reference, but didn’t work for me. Do you think it might be the express version I have? does using app.use(express.static("public")); makes it env-dependent? how come?
Thanks,
Ale
Hello, Alejandro! Thank you for reading the blog post and also for joining our Auth0 Community. Today, I’ve been working on some Express content and I’ve been auditing this blog post. Let me run this again and see if I can spot any problems
Alejandro, I just tested this blog post from start to end and I saw no error and all the assets were served correctly. This is what my package.json looks like:
__dirname corresponds to the root project directory as it is the parent folder of the index.js file where that statement is being executed. For that file reference to work, the public directory must be a sibling of the index.js file as well. If you place public in another area or within a directory that is child to the root project directory, the reference won’t work.
The use of path.join is to create file paths that work across operating systems. So if that statement is run on Windows, you’ll get the right pathname delimiters for Windows – the same goes for macOS, Linux, etc. Some operating systems use / while others use \ to delimit file paths.
I’d recommend taking a look at your project structure to ensure that the references work. Please let me know if you have further questions Happy to help!
Hello, Manyhp. Welcome to the Auth0 Community. That first app.get ("/", (req, res) => { … }); is a placeholder for the existing code to help you visually identify where you need to add the new function:
small error in user.pug template.
maybe I’m wrong. ((
in template →
div.NavButtons
a (href = “/ logout”)
div.NavButton Log out
But we have no direction “/ logout”
am i wrong?
it worked for me without the word “logout” → like this
div.NavButtons
a (href = “/”)
div.NavButton Log from
to go to the Hpme page
Howdy, we tested this tutorial recently as we are launching an update soon as we found no errors. Could you use code fences please so that the code is formatted? Pug is whitespace sensitive and a missing tab may cause trouble.
You can create a code fence by typing the backtick (`) three times, then press enter, then type the backtick three times again. Finally, you can paste your code between the backtick (the fence). This will help the code you paste keeps its formatting.
Hey Dan, thank you for the great tutorial! I enjoyed following it.
The only issue I have would be similar to @haiemh’s issue. Running the command npm run ui doesn’t load the page at all, seems like browser sync is not working properly. Any thoughts on what could be the problem?