title: Why does omitting the line app.use(express.static(__dirname, 'public')) stop my html pages from loading css files?
body: <p>I'm learning to use NodeJS and Express and just used "express" to generate the scaffolding for a project. I don't understand the purpose of:</p>
  
  <p><code>app.use(express.static(path.join(__dirname, 'public')));</code></p>
  
  <p>My understanding of app.use() is that it loads functions as middleware, so <code>app.use(express.static(path.join(__dirname, 'public')))</code> must be loading a function, right? Is this function loading paths to some files that I'm declaring as static?</p>
  
  <p>In my layout.jade file, I have this line in the head:</p>
  
  <p><code>link(rel='stylesheet', href='/stylesheets/style.css')</code></p>
  
  <p>How does my app know to begin the href link with a '/public' (if that's what it's doing) when I set the <code>app.use(express.static)</code> line? Because when I get rid of the <code>app.use(express.static)</code> line, it gives a 404 to finding the css file, even when I change the href to '/public/stylesheets/style.css'. </p>
  
  <p>And how does it know that I'm trying to access that static file at all? What if I had a file called 'root/stylesheets/style.css' as well as the 'root/public/stylesheets/style.css'?</p>