Configuration

You can setup several options on the configuration file, config.yml (default).

The example below is a basic configuration for ttl2html:

base_uri: https://www.example.org/
output_dir: /var/www/html/dataset/
labels:
  http://www.w3.org/1999/02/22-rdf-syntax-ns#type: Class
  https://schema.org/name: Title
site_title: A sample dataset
title_property: https://example.org/title
top_class: https://schema.org/Book

Configuration parameters

All configuration keys available are documeted as follows:

about_file
Default:
about.html

Specified filename is used for documenting schemas of the dataset. It requires SHACL documentation within the dataset. By default, the filename about.html is used.

Addional links displayed at the top menu. Specify an array of link items with two keys href and label. e.g. [ { "href": "http://example.org", "label": "Link" } ]

admin_name

Name of the dataset publisher displayed at the footer.

about_toc
Type:
boolean
Default:
false

true / false to specify whether to output a table of contents in about.html. The default is false, which means no table of contents.

base_uri

[required] Base URI for the dataset. Base URI is considered as the prefix for the target resources, and only the matched URIs with the prefix are picked up for the generation.

breadcrumbs

Configuration for creating a hierarchical breadcrumb list of multiple resources. Define a list of properties that are higher level resources or related resources of the resource. In the example below, the schema:hasPart and jp-cos:hasOfStudy properties, if present, respectively, are used to construct the navigation menu by considering resources linked from the current resource to be higher-level resources. The default display label on the breadcrumb list is “title”, but if the label attribute is defined, the value of the property defined in the label attribute can be used as a breadcrumb link. Also, if the inverse attribute is present, then the resource being transitioned to as a property to the current resource is considered to be a higher level. It is also possible to specify a resource that spans a multi-level relationship with an empty node, etc. In that case, add a list to the property attribute and add a property attribute to its subordinate items as well. At the end of the example below, the schema:isPartOf property of the resource to which the schema:workExample property of the resource in question is specified can be used as a navigation resource.

breadcrumbs:
  - property: https://schema.org/hasPart
    inverse: true
    label: https://w3id.org/jp-cos/sectionNumber
  - property: https://w3id.org/jp-cos/courseOfStudy
  - property:
    - property: https://schema.org/workExample
    - property: https://schema.org/isPartOf

Copyright year statement displayed at the footer along with the admin_name parameter above.

css_file

The path of the CSS stylesheet file(s) to use. You can specify either a single file or multiple files:

Specifying a single file
css_file: style.css
Specifying multiple files
css_file:
  - reset.css
  - layout.css
  - theme.css
custom_css

Specify the code snippet of the CSS stylesheet.

Example of custom_css setting
custom_css: "nav.navbar { background-color: pink }"
google_analytics

Google tracking code for usage statistics by Google Analytics.

google_analytics: G-XXXXXXXXXXXX
google_custom_search_id

Specify the search engine ID for setting up a site search form using Google Custom Search.

google_custom_search_id: 0123456789
javascript_file

The path of the custom JavaScript file(s) to use. You can specify either a single file or multiple files:

Specifying a single JavaScript file
javascript_file: public/script.js
Specifying multiple JavaScript files
javascript_file:
  - lib/jquery.min.js
  - lib/d3.min.js
  - custom.js
labels

Specify the custom label name for each property. Specify the property URI as the key and the label name as the value.

For example, the following setting specifies that the dct:description property should be displayed as “Item details”:

labels:
  http://purl.org/dc/terms/description: Item details

If you need to change the label for each class, use the labels_with_class setting or the shape method.

If you do not specify a name for the property using these settings (default), the string at the end of the property URI with the first letter capitalized will be displayed.

For example, dct:description will be displayed as “Description,” and schema:name will be displayed as “Name”.

labels_with_class

labels_with_class is a configuration item that specifies the property name for resources belonging to a specific RDF class. Use this when you want to give different names to the same property for each class.

The name is specified with the class URI as the key and each property URI and its name as the value.

For example, in the following example, the dct:description property is represented as “Item details” for resources of the ex:Item class, and “Detailed text” for resources of the ex:Work class:

labels_with_class:
  https://example.org/Item:
    http://purl.org/dc/terms/description: Item details
  https://example.org/Work:
    http://purl.org/dc/terms/description: Detailed text

There is a method for more detailed labeling, using shapes.

Also, if you don’t need to distinguish between classes, specify it using the labels setting.

locale
Default:
en

Locale name for the output messages. Default: en (e.g. ja, en)

The logo image file to be displayed on the menu. Specify the file path or URL.

navbar_class

Specifies the class setting for displaying the navigation bar at the top of the screen. If not specified, navbar-light is used. Use this if you want to specify a black background color as follows:

navbar_class: navbar-dark bg-dark
ogp

Specify OGP (Open Graph Protocol) settings if you have additional logo settings for social networking sites, etc. You can specify ogp:image, ogp:type, etc.

ogp:
  image: https://example.org/logo2.png
  type: article
output_dir
Default:
.

Output directory for the dataset. If not specified, the current working directory is used for the outputs.

output_turtle
Type:
boolean
Default:
true

Whether to output the RDF/Turtle format file corresponding to each resource URI, as true / false. Default is true (i.e. output RDF/Turtle format files).

shape_orders

This configuration option controls the order in which resource descriptions are output to about_file. The descriptions are output in the order of the resource shapes listed here. If not set, the default is alphabetical order of shape URIs. Set as a list, as in the following example:

shape_orders:
  - https://example.org/ItemShape
  - https://example.org/BookShape
site_title

Main title for the whole website.

template_dir
Default:
templates/

Local template directory to find a template file. Default template files are available at here. To overwrite the contents of the original template, copy the original file to the directory specified here and rewrite it.

subtitle_property

Specifies the property to be used globally (common to all classes) as a subtitle. While the title (settings from title_property or title_property_perclass) is usually displayed in the header of an individual resource, there are times when you may want to include additional information (e.g., volume number, edition, date, title, etc.) as a subtitle on the same or following line.

subtitle_property and subtitle_property_perclass are settings that control which property value is used for the subtitle.

Subtitles can be displayed in two places:

  • Directly below the header on the resource details page

  • As an auxiliary display for each resource link in the resource details table.

subtitle_property_perclass

Specifies the property to be used per class (priority) as a subtitle.

title_property

Specified URI is regarded as a title property for the resource. In default, a title is matched with the following properties:

title_property_perclass

This setting specifies property URIs for each class URI. If a specified property exists on a resource, its value will be used as the title of the generated resource page.

For example, in the following case: Resources of the foaf:Person class use the foaf:name property as the title, while resources of the example:Item class use the dct:description property as the title.

title_property_perclass:
  http://xmlns.com/foaf/0.1/Person:
    http://xmlns.com/foaf/0.1/name
  http://example.org/Item:
    http://purl.org/dc/terms/description

If a resource does not belong to a class specified in title_property_perclass, the title_property setting will be used.

top_additional_property

For each set of resources expanded by top_class setting, specify a list of additional sub-hierarchies to be expanded. The properties that make up the sub-hierarchy are specified as a list.

top_class

Specified URI is the class of the records listed in the top page. By default, this tool does not generate the top page.

uri_mappings

If you want to change the output file names when outputting local files corresponding to a URI, use this setting. You can specify the patterns for the part of paths in a URI and then determine how the matched part of the path has to be changed. For example, when outputting many files in a single directory, you can specify a pattern for the first few characters and the rest of the filename so that each directory contains a separate set of files with different destinations. The example below specifies that a URI path consisting of 16 alphanumeric characters is divided into the first three characters and the rest of the path. Hence, the output files are placed for each two-character directory.

uri_mappings:
  - regexp: !ruby/regexp /^(\d\w\w)(\w{13})$/
    path: '\1/\2'