Creating Content

Now it's time to create some content for your site. In Maven 2, the site content is structured by format, as there are several formats supported.

Here's an example of a directory structure for a site:

+- src/
   +- site/
      +- apt/
      |  +- index.apt
      +- fml/
      |  +- general.fml
      |  +- faq.fml
      +- xdoc/
      |  +- other.xml
      +- site.xml

The ${basedir}/src/site directory which contains a site descriptor along with various directories corresponding to the supported document formats. Let's take a look at examples of the various document formats.

The APT format ("Almost Plain Text") is a wiki-like format that allows you to write simple, structured documents (like this one) very quickly. A full reference of the APT Format is available.

The FML format is the FAQ format. This is the same that were used in Maven 1.x. For more info about the FML Format check the Doxia site.

The XDoc format is the same as used in Maven 1.x. A reference for the XDoc Format is available.

Other formats are available, but at this point these 3 are the best tested. There are also several possible output formats, but currently only XHTML is available.

Note that all of the above is optional - just one index file is required in one of the input trees. The paths under each format will be merged together to form the root directory of the site. After running 'mvn site:site' on the example above you will end up with this in your target directory:

+- target/
   +- site/
      +- css/
      +- images/
      +- index.html
      +- general.html
      +- faq.html
      +- other.html

This means that /src/site/apt/index.apt will be available in the site as /index.html. So, in your site descriptor you might link to /index.html and /other.html, where the source of these two files would be /src/site/apt/index.apt and /src/site/xdoc/other.xdoc.

The css and images directories contain stylesheets and images from the skin being used. You can read more about skins in the site descriptor documentation.

Adding Extra Resources

You can add any arbitrary resource to your site by including them in a resources directory as shown below. Additional CSS files can be picked up when they are placed in the css directory within the resources directory.

+- src/
   +- site/
      +- resources/
         +- css/
         |  +- site.css
         +- images/
            +- pic1.jpg

The file site.css will be added to the default XHTML output, so it can be used to adjust the default Maven stylesheets if desired.

The file pic1.jpg will be available via a relative reference to the images directory from any page in your site.


Note: This feature is available in version 2.0-beta-6 or later of the Site Plugin.

To filter properties into any supported documentation format, add a .vm extension to the filename.

For example, the module for the Maven website contains a src/site/apt/download.apt.vm file, which uses the expression ${currentVersion} to filter in a property set in the POM.

Note: Velocity is used to apply the filtering. Because Velocity uses a dot-notation internally you can not use dots in your properties.

If you declare these properties in your POM

    <!-- This will not work because the name of the property has a dot in it -->
    <>My value</>
    <!-- This will work because the name of the property has no dot in it -->
    <myProperty>My other value</myProperty>

and then use the expression ${} in your document, it will not work. If you instead use the expression ${myProperty} it will work just fine.


Internationalization in Maven is very simple, as long as the reports you are using have that particular locale defined. For an overview of supported languages and instructions on how to add further languages, please see the related article Internationalization.

To enable multiple locales, or languages, add a configuration similar to the following to your POM:


This will generate both an English and a French version of the site. If en is your current locale, then it will be generated at the root of the site, with a copy of the French translation of the site in the fr/ subdirectory.

To add your own content for that translation instead of using the default, create a subdirectory with that locale's name in your site directory and create a new site descriptor with the name of the locale in the file name. For example:

+- src/
   +- site/
      +- apt/
      |  +- index.apt     (Default version)
      +- fr/
      |  +- apt/
      |     +- index.apt  (French version)
      +- site.xml         (Default site descriptor)
      +- site_fr.xml      (French site descriptor)

With one site descriptor per language, the translated site(s) can evolve independently.