====== Exporting ======

**Zim** will be able to export content to various formats but at the moment only exporting to (simple) Html is supported.

To open op the export dialog in **zim** use the "//File//->//Export//" menu item. This dialog asks for a number of input fields before you can start exporting.

To select the **Pages** you want to export you can check "All" if you want to export the whole tree, or you can check "Page" if you want to export a selection.

When you make a selection you can enter one or more pages or namespaces in the text entry field separated by spaces. namespaces always end with a ":", pages do not. The **Recursive** option automatically adds the coresponding namespace for each page when set.

The **Format** is fixed on "Html" for now. Later other options will be added here.

The **Template** field asks you to select a template file (see below). When you select "''other...''" in the combo box you can fill in a file name in the text input field below the combo box.

Finally an **Output dir** is required, this is the directory name where you want to save the exported pages. This can be a non-existing directory. You can use "''~/''" to refer to you home directory here.

If you specify an **Index page** a page will be autogenerated that contains a list with links to all pages that were exported. This can e.g. be used as a site map.

The **Media** section allows you to choose what you want to do with linked files and images. Files in images that live inside the notebook directory (attachments, equations etc.) will always be copied to the new directory, but the behavior for files and images outside the notebook directory can be changed.

* If you use a [[preferences|document root]] you can use the and **"Prefix document root"** option to map all paths in the document root to another path or URL. This is useful for example when you want to export to a website that maps the document root under a certain URL. If you disable this option all paths in the document root will be regarded as normal external files. See "[[attaching files]]" for more details.
* The **"Attach external files"** option allows you to package all external files with the exported notebook. Copies of all files and images outside the notebook (and outside the document dir, depending on the above setting) that are linked will be stored under "_media" in the export directory.

===== Templates =====

The export code only produces the tags that represent the content of the page. It does not add elements like a <head> section. [[Templates]] are used to create complete Html pages. A few [[templates|standard templates]] are packaged with **zim**, but you can also make your own.

===== Exporting from the commandline =====

Try something like:

	$ zim --export \
	  format=html,template=./foo.html,dir=./html,media=copy \
	  ~/docs/zim :notes:

This should export the "''notes:"'' namespace from "''~/docs/" ''to Html using template "''foo.html"''. The "root" of the export string is the directory used for the exporter output.

You can also add the option ''recurs=0'' if you don't want to export sub-namespaces. This option defaults to 1.

===== TODO =====
* Set an header offset, for example if offset is 2 all head1 => head2, all head2 => head3 etc. This is useful when the template also contains headers. 
* Have the option to compile a namespace into one big page.
