     after_category: (ctx, category) ->
       return unless category == @category
 
+      @layoutFile ||= layoutFiles[@layoutFilename]
+      throw("No layout #{@layoutFilename} found for #{category}") unless @layoutFile
+
       adapter = @layoutFile.adapters[0]
       content = @layoutFile.originalContent
       opts = @configure_options(@layoutFile, adapter)

    )
  array

module.exports = (options) ->
  options ||= {}
  folder = options.folder || "posts"


      before_pass: (ctx) ->
        f = ctx.file
        if f.file.relative == extension.layoutFilename
          f.originalContent = f.content
          layoutFiles[extension.layoutFilename] = extension.layoutFile = f
        else
          entries = extension.roots.config.locals[helperName]
          entries.push(extension.read_file(f))
