Here is the standard project structure you'll see in DocPad projects:
documents/, for backwards compatibility)
files/, for backwards compatibility)
This directory contains anything that DocPad generates. Any new files added to the
sourcedirectory will be found here after being rendered and written by DocPad. However any files that are deleted from the
sourcedirectory will not be deleted from the
outdirectory by DocPad, you have to delete them manually. So if you remove a file and it's still there remember to delete it manually. ;-)
This directory contains your website's source files. It contains your layouts, files to be rendered and be in the output and files that are not to be rendered but will still be in the output. The
sourcecan have the following folders:
documents, for backwards compatibility, for backwards compatibility))
documentsdirectories, and the
filesdirectories, are merged; files appearing in either are rendered or copied to the output. However, you should use the former names rather than the latter to conform with the latest naming conventions.
The layouts Directory
Layouts work in a very similar way to files in
render, in that they are rendered and they support meta data. Unlike the files in
render, however, they are not output to the
outdirectory, as they only exist to wrap files in
renderand other layouts within themselves. Layouts work in a nested fashion, with the desired layout being defined by the
layoutmeta data property within the child layout/document.
Layouts should include child content, which is done using the
contenttemplate data variable. For instance, the code to use the content variable with the Eco templating engine via the Eco DocPad plugin would be
<%- @content %>.
The render Directory
These are files that we would like to render. Rendering occurs extension to extension in the same way the Ruby on Rails asset pipeline works. This means the document
source/render/hello.ext1.ext2.ext3is rendered from
ext2, then from
ext1, resulting in the file
out/script.jsor writing a blog post that renders from Markdown to HTML with the document
The reason we do not support direct rendering from
script.jsis that such a convention would eliminate the ability to combine extension renderings, also because ambiguity between extensions that can be rendered in multiple ways. For instance the
The other important aspect of files in
renderis that they support meta data. Meta data goes at the top of a document and defines information about that particular document. For instance, its title, date and layout are good examples. Meta data is not restricted to particular values, meaning you can define whatever meta data you want against a document. There are some special meta data properties, however, that perform certain functions (e.g.,
layoutis used to specify the layout that should be used to wrap the document). You can find the complete listing of special meta data properties on the Meta Data page.
The static Directory
Files in this folder, like those in
render, are output to the
docpad.coffeefile can have several different extensions. It defines DocPad's settings. You can find full documentation on the Configuration docs page.
This file is needed for every Node.js application. It defines the dependencies that your application requires, such as the DocPad version that your site is developed with and the plugins you are running. You can learn more about
package.jsonfiles on this page of our Hands on Node Training.