Publishing javadoc to github using maven

GitHub has the ability to publish static site documentation using GitHub pages.

This can be used in your project to publish for example the javadoc.

For starters, you need to create a gh-pages branch in your project (example here is for my user (joachimvda) and the jtransfo project).

git clone
cd jtransfo
git checkout --orphan gh-pages
git rm -rf .
cat "placeholder" >index.html
git add index.html
git commit -am "initial pages commit"
git push origin gh-pages

Now add a section to your pom to generate the javadoc and publish to the gh-pages branch. In this case, I aggregate the javadoc for all modules. Add the following to the build/plugins section:

        <header>jTransfo, ${project.version}</header>
        <footer>jTransfo, ${project.version}</footer>
        <doctitle>jTransfo, ${project.version}</doctitle>
        <checkinComment>Publishing javadoc for ${project.artifactId}:${project.version}</checkinComment>
        <scmBranch>gh-pages</scmBranch> <!-- branch with static site -->

You can now build and publish the javadoc by using the following maven command:

mvn clean javadoc:javadoc scm-publish:publish-scm

The pages are now accessible at

Add a nice link from your



  1. […] For details on how this was done, see here. […]

  2. bennidi says:

    Concise explanation. THank you so much, it worked exactly as described. Small improvement for the tutorial: Before running the maven command you have to switch back to the master branch (obvious but for the sake of completeness… 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen