Most of our users are happy to use the markup created in our simple authoring tool to publish their timeline. However, if you want to substantially customize the visual presentation of your timeline, or integrate it with other parts of your page, you will need to understand some more technical details.
There are three key things you need to include on your page to embed a timeline:
linktag loading the Timeline CSS.
- A second
scripttag which creates a Timeline.
linktag for custom fonts.
linktag to override some of TimelineJS's CSS.
Creating your own JSON
If you are retrieving JSON from a URL, you can simply use that URL as the second argument, just as if you are loading data from a Google spreadsheet. If instead you have something in your page which will put the data together, you can also pass a JSON object as the second argument.
Create the JSON according to our specifications and then change step 3 to look like this.
Configuring TimelineJS options
TL.Timeline offers an optional third parameter which you may use to pass in additional TimelineJS options. See our list of available options and configure like the example below.
Using custom fonts
Timeline offers several pre-selected font sets. When you use our simple tool, the fonts get included for you, but if you're using the methods on this page, you'll have to load them yourself.
To include them, use markup like this, a variation on step 1 above.
<!-- 1 --> <link title="timeline-styles" rel="stylesheet" href="https://cdn.knightlab.com/libs/timeline3/latest/css/timeline.css"> <link title="timeline-styles" rel="stylesheet" href="https://cdn.knightlab.com/libs/timeline3/latest/css/fonts/font.abril-droidsans.css">
Of course, you'll change
font.abril-droidsans.css according to which fonts you choose. Here are all the values which you might use there:
You can download a model copy of a typical font CSS file from our CDN. You may want to put it through a CSS formatter before you start to edit it. If you are familiar with LESS, you may prefer to work from our LESS files on GitHub.
Loading Files Locally
Unpack the ZIP and include it on your web server, and load the JS (either
timeline.min.js) and CSS (
timeline.css) files from it instead of from `cdn.knightlab.com`. If you are using the default fonts and English language, you only need those two files.
However, if you plan to use other languages and font sets, putting the entire contents of the ZIP on your server is necessary to fully support all of Timeline’s features.