Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics (2015) Serving Static Files in Express Setting Up the Express Static Server in Development

Why are we using '/static' - as opposed to '/public'?

Curious as to why we use '/static' vs any other term, especially '/public'?

3 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

I haven't seen this particular video but static and public are both common directories for "static assets" or "publicly accessible assets".

Anthony c
Anthony c
20,907 Points

Is there an upside to passing the files through "/static"?

Why not just name the "public" folder "static" to begin with?

why this?

app.use('/static', express.static(__dirname + '/public'))

and not this

app.use(express.static(__dirname + '/static'))
Matthew Day
Matthew Day
6,740 Points

I would love to know the answer to this, as well.

.static is built in middleware for Express.js. So using /static directory to store all your static asset files is -- although extremely helpful -- simply a naming convention.

In the context of the massive info dump that comes with inevitably distilling a complex toolset into a few short videos, this can seem like just one more little thing to remember.