Fortunately, Jade is very opinionated so there's not many things that we can write differently. Try to stick to the following:

  • Use 2 spaces for indentation.
  • Use 1 newline between chunks of code and 2 newlines between larger sections of code.
  • Keep your code DRY. If there's a section of code repeated, create a mixin for it and reduce code bloat.
  • Use block expansion when possible to keep your files shorter
  • When an element has many attributes separate them onto individual lines with no commas at the end.
  • Don't specify a value for attributes that are true or empty.
  • Avoid inlining plain HTML. Keep your code legible.
  • Keep as much logic as possible away from the Jade templates. Put it in a controller.
  • Only use unbuffered comments. HTML comments bloat the code that gets sent to the client.
  • Use Jade iterators in place of javascript in control code.