The Twig engine provides a number of options to assist with debugging. Enabling overall debugging adds comments around each Twig template, showing the theme hook and any template suggestions:

Turning on Twig debugging also enables some additional functions inside the Twig templates. Inside a Twig template, you can place {{ dump(var) }} to output the value of a given variable. If you have the Kint submodule from the Devel module enabled, you can also place {{ kint() }} in your template, which will display the full context available to the template, all variables, and theme hook suggestions.

By default, Twig compiles templates into PHP code and stores that compiled PHP in cache directories. This makes rendering the Twig templates faster since that compilation process can be expensive, but it requires a full cache rebuild in order to see changes to the Twig templates. To enable this auto-reload process, edit your /sites/default/services.yml file, find the section for twig.config, and change auto_reload: null to true. If you have enabled Twig debugging, you can leave this as null and it will inherit from that setting. When auto-reload is enabled, it ensures that the Twig templates are re-compiled every time they are changed. It is recommended that you do disable the auto-reload functionality in production.