Drupal 8 Developers Cookbook: Render Arrays

A core part of the Drupal 8 page assembly process is the use of render arrays in lieu of components generating their own HTML output.  As with much of Drupal, it's not a hard concept to learn - it just hasn't been documented well, and discovering what components are available to you is tricky to figure out.

So, a quick primer on the basics.  Drupal 8 uses the Twig template engine to generate the HTML output for a page.  Twig is driven by data structures called render arrays that provide the raw information that will then get encapsulated in HTML by Twig.  Drupal actually provides a number of Twig "themes" out-of-the-box, but for fancier layouts, you can create, your own Twig template and use it in your render arrays.

Drupal extends base Twig a bit, so the best way to get started with the Drupal version is by reading over the Drupal.org "Twig in Drupal 8" documentation section.