Overview of what static site generation actually means, how it compares to dynamic based sites and areas of cross-over between the two. Then delves deeper into Metalsmith as the Node.js tool used to demonstrate the generation process.
server-side language • 3rd party code (modules, libraries, extensions) need monitoring • Ensuring that your server-side code is secure when processing requests • Database vulnerabilities can be a concern.
a web server to attack. • Faster, no databases or server-side processing to construct the page. • Fewer points of failure. • Easily cacheable or hosted across multiple servers. • Easier to debug, the HTML served only change when you regenerate. 17
dynamic server pages. • Static generated site, backed by an API and client side JavaScript for dynamic components. • Dynamic content management system producing a static based site. 19
in the ./src directory. 2. Parse files for `front-matter` ◦ Idea lifted from Jekyll, another static site generator (Ruby). ◦ front-matter uses YAML for defining data 3. Manipulate file data through series of plugins. 4. Write the results to a ./build directory.
.use(fn) method. • Plugin is provided with a list of files found and parsed by metalsmith. • A reference to the metalsmith instance. • Callback function to signal plugin is complete, useful for async operations.
multiple groups. • Useful for providing listings such as a list a blog posts or an index of pages. • Collections are array based, easy to slice into smaller chunks or to iterate. 36
your pages. • Use metadata collected from the parsed files. • Example: {pattern: ‘:date/:title’} • Creates a file within the path and provides a new `. path` attribute in the file data. • Also supports date formatting ◦ {pattern: ‘:date/:title’, date: ‘YYYY-MM-DD’}
post index. ◦ Support tags and categories. • Search support (Google Custom, Lunr.js). • Comments (Disqus, Discourse, Isso). • RSS feeds, Social media sharing. • Contact form (Google Docs, Wufoo) • Highlight code (Prism, Highlight.js)