How do I get clean output with indented structure How can I create a clean theming markup so that the output uses the same indented structure as in my static html template? E.g. when I insert $head;  Drupal uses it’s indenting format. 

How can I control the ouput?

snippet from the html.tpl.php

&lt;head&gt;

  &lt;title&gt;&lt;?php print $head_title; ?&gt;&lt;/title&gt;
  &lt;?php print $head; ?&gt;
  &lt;?php print $styles; ?&gt;

&lt;/head&gt;


The output looks like this 

&lt;head&gt;

  &lt;title&gt;Lorem Ipsum | mothership&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="Generator" content="Drupal Mothership" /&gt;
&lt;link rel="canonical" href="/d7-demo/node/1" /&gt;
&lt;link rel="shortlink" href="/d7-demo/node/1" /&gt;
  &lt;style media="screen"&gt;
@import url("http://localhost/d7-demo/modules/shortcut/shortcut.css?nmdogy");
@import url("http://localhost/d7-demo/modules/toolbar/toolbar.css?nmdogy");
@import url("http://localhost/d7-demo/sites/all/themes/mothership/mothership/css/mothership.css?nmdogy");
@import url("http://localhost/d7-demo/sites/all/themes/itsgoodtobehere/bootstrap/css/bootstrap.min.css?nmdogy");
&lt;/style&gt;

&lt;/head&gt;


instead of 

&lt;head&gt;

  &lt;title&gt;Lorem Ipsum | mothership&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;meta name="Generator" content="Drupal Mothership" /&gt;
  &lt;link rel="canonical" href="/d7-demo/node/1" /&gt;
  &lt;link rel="shortlink" href="/d7-demo/node/1" /&gt;
  &lt;style media="screen"&gt;
    @import url("http://localhost/d7-demo/modules/shortcut/shortcut.css?nmdogy");
    @import url("http://localhost/d7-demo/modules/toolbar/toolbar.css?nmdogy");
    @import url("http://localhost/d7-demo/sites/all/themes/mothership/mothership/css/mothership.css?nmdogy");
  &lt;/style&gt;

&lt;/head&gt;
HTML Tidy can do what you're wanting, but this is designed as text format, Configuration » Content authoring » Text formats which are used in fields rather than the whole site.

Is should be possible with some work to pass the entire theme though HTML Tidy