# Generate documention with mutiple versions

**URL:** <https://forum.crystal-lang.org/t/generate-documention-with-mutiple-versions/5907>\
**Category:** Learning Resources\
**Created:** [August 3, 2023, 5:28pm UTC](https://forum.crystal-lang.org/t/generate-documention-with-mutiple-versions/5907 "2023-08-03T17:28:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fulgurance](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fulgurance/32/1463_2.png) [@Fulgurance](https://forum.crystal-lang.org/u/Fulgurance)\
**Post date:** [August 3, 2023, 5:28pm UTC](https://forum.crystal-lang.org/t/generate-documention-with-mutiple-versions/5907/1 "2023-08-03T17:28:40Z")

</div>

Hi everyone,

Today I would like to share to you a tutorial I made to know how to generate a documentation for your project in Crystal.

_I will show you an example with my own project **ISM** (this tutorial was realized on Gentoo Linux)._

So first go inside the directory of your main project.  
 ![CrystalDoc1](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/a/a2dbf68256177f34a7ce6ec6c07edf0319be236f.png)

Open a terminal at this location.

 ![CrystalDoc2](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/4/41039067905092f3d7a98f64429e8b5811e44414.png)

Now type in the terminal:

```auto
crystal docs --json-config-url=versions.json

```

If your project don’t use shard, like my project, you will need to specify more options, the project name, and the main file of your project.

 ![CrystalDoc3](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/4/48060b39349d7ebcca5a2bdc1ba5ab9cbf669ceb.png)

The option **–json-config-url** set which file will control the redirection to the other version pages. You can set the name you wish for this file. This file will inform the website when the user will be on the current page where the website we will need to come back if the user will request to see an another version.

This file look like that for me actually. Just adapt it for your project:

```auto
{
  "versions": [
    {"name": "Alpha-06012023", "url": "/api/Alpha-06012023"},
    {"name": "Alpha-13022023", "url": "/api/Alpha-13022023"},
    {"name": "Alpha-14032023", "url": "/api/Alpha-14032023"},
    {"name": "Alpha-07072023", "url": "/api/Alpha-07072023"}
  ]
}

```

You need to make this file for each versions you will generate, or the user will not be able to come back to the main page of your documentation.

So of course, you need to adapt this file for each version to make sure the user will be able to come back to the main page (master in my case).

Actually we generate the main page, because by default my project is on master branch. Everything was generate in the _ **./docs** _ directory.

Now clone your repository somewhere else and repeat the same action for each version you need to generate a documentation.

When it’s done, in your main project directory on master, in **./docs** , make a directory for each branch you generated the documentation before. And copy inside each directory the content of related generated documentation.

As I said previously, don’t forget to make a _ **versions.json** _ file for each directory.

Normally your directory will look like that:

 ![CrystalDoc4](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/f/fc6b06a09d283d9acbfa70d8350eb18d3db3ecd3.png)

_Now just copy all of that in your server, and it’s done !_

---

<div class="post-metadata">

**Author:** ![nobodywasishere](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/nobodywasishere/32/1983_2.png) [@nobodywasishere](https://forum.crystal-lang.org/u/nobodywasishere)\
**Post date:** [August 3, 2023, 6:08pm UTC](https://forum.crystal-lang.org/t/generate-documention-with-mutiple-versions/5907/2 "2023-08-03T18:08:13Z")

</div>

While working on crystaldoc.info, I ran into this too. Thank you for the tutorial! The versions.json can be anywhere on the server/docs, and the json-config-url option just sets the path the browser should get the versions.json from. If you put it at the root of your docs, you can do `--json-config-url=/versions.json` and everything should work.
