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 Using jQuery Plugins Add a Sticky Navigation Bar Adding Sticky Navigation

Daniel Bettech
Daniel Bettech
7,365 Points

Including code pieces into master file

Hello,

I see in the video that Dave is writing duplicated code thru all the html files. Is there a more efficient way to include code snippets into the files? For example all the css and js files, links navigation. I mean like a wordpress structure.

Dave is using only 3 html files, but a site with dozens of pages would be a real mess.

Very interesting module! Thanks

2 Answers

This is where Sass partials and gulp/grunt/webpack come in to play. the file structure for the css is you use one main .scss/.sass file that imports your sass partials then you use your build tool like gulp to compile the sass to css and then minify the CSS into an "dist" folder that goes out to production.

The Js is done pretty much the same.

The index.html is just that. It's not php like Wordpress, so you need to manually add the link tags to the head of the page. .html files do not have a database to draw from so you need the link tags. This is one of the main differences between dynamic and static.

Daniel Bettech
Daniel Bettech
7,365 Points

Thanks for the feedback Jacob