Contents

Usage Guide

Guide to generating an ontology companion site using OCG.

This guide shows how to add OCG to an existing ontology repository, point it at your current source files, customize the generated pages, and publish the companion site from that repository's main branch.

Existing Repository Integration

Keep your ontology repository as the source of truth and install OCG alongside it.

  1. Install the package. Run npm install --save-dev ontology-companion-generator. The package supplies the generator, schema fallback, branding, Sigma.js, Graphology, and RDF parser dependencies.
  2. Initialize the repository. Run npx ocg init --ontology vocab/my-vocabulary.ttl. OCG creates the config, schema, Pages workflow, and npm scripts, and attempts to infer the namespace and common companion files.
  3. Review and customize the config. Paths in sources are relative to the repository root, so an existing vocab/, shapes/, shex/, examples/, or spec/ layout can remain unchanged.
  4. Validate and build. Run npm run ocg:check, then npm run ocg:build. Use npm run ocg:dev to inspect the generated site locally.
  5. Publish from main. Enable GitHub Actions as the Pages source and push main. Feature branches should build and validate without deploying over the live site.

Existing source layout example

{
  "sources": {
    "ontology": "vocab/my-vocabulary.ttl",
    "ontologyFormat": "turtle",
    "shapes": "shapes/my-vocabulary.shacl.ttl",
    "shex": "shex/my-vocabulary.shex",
    "spec": "spec/index.html",
    "examples": [
      {
        "key": "basic",
        "label": "Basic Example",
        "path": "examples/basic.ttl",
        "description": "A minimal valid instance graph."
      }
    ]
  }
}

Required integration files

OptionDescription
ocg.config.jsonProject-specific metadata, source paths, feature switches, graph settings, theme, and curation.
package.json + package-lock.jsonThe OCG package and its locked dependencies.
.github/workflows/publish-pages.ymlBuilds and deploys site/ from main through GitHub Pages.
ocg.config.schema.jsonOptional local copy created by ocg init for editor completion.
Do not copy OCG internals into the ontology repository. The installed package owns the generator code and browser assets. The ontology repository owns the config, source files, package manifest, workflow, and generated site.

Getting Started

The primary workflow adds OCG to an existing ontology repository; forking this repository is an optional alternative.

  1. Keep your existing source layout. OCG can use ontology, SHACL, ShEx, example, and ReSpec files wherever they already live in the repository.
  2. Update the config. Change project metadata, source paths, feature switches, graph options, theme, landing-page copy, and generator links in ocg.config.json.
  3. Build locally. Run npm run ocg:build to regenerate site/ and vendor the Sigma.js/Graphology browser bundles under site/assets/vendor/, then inspect the pages.
  4. Publish with GitHub Pages. Push the ontology repository's main branch. The workflow rebuilds and deploys site/ through GitHub Actions.

Repository Layout

OCG support files can sit beside an existing ontology layout; source paths do not need to use source/.

.
├── ocg.config.json
├── ocg.config.schema.json
├── package.json             # contains the OCG dependency and scripts
├── package-lock.json
├── vocab/                   # existing ontology files
├── shapes/                  # existing SHACL files
├── shex/                    # existing ShEx files
├── examples/                # existing instance data
├── spec/                    # existing ReSpec source
└── site/                   # generated, do not edit by hand

Accepted Input Formats

OCG currently parses a deliberately small set of RDF serializations for the primary ontology.

OptionDescription
TurtleAccepted extensions: .ttl and .turtle. Auto-detected as text/turtle.
RDF/XMLAccepted extensions: .rdf, .rdfxml, and .owl. Auto-detected as application/rdf+xml.
JSON-LDAccepted extension: .jsonld. Auto-detected as application/ld+json.
N-TriplesAccepted extensions: .nt and .ntriples. Auto-detected as application/n-triples.
sources.ontologyFormatUse auto for extension detection or explicitly set turtle, rdfxml, jsonld, or ntriples when needed.
Optional source filesSHACL, ShEx, example, and ReSpec files are copied or published as configured. They are not currently parsed into the generated ontology graph.
Not currently accepted as primary ontology inputs: TriG, N-Quads, N3, OWL Functional Syntax, Manchester OWL Syntax, OWL/XML, OBO, arbitrary XML/JSON/YAML, CSV, UML/XMI, JSON Schema, OpenAPI, and Protobuf. OCG rejects these instead of guessing a semantic mapping.
{
  "sources": {
    "ontology": "source/ontology/my-vocabulary.jsonld",
    "ontologyFormat": "jsonld"
  }
}

Companion Site Components

Use the component-level How To links throughout the site to return directly to these explanations. Each detailed section includes an option table and a complete example.

Developer Workflow

Package and CLI

Install OCG as a development dependency and use the CLI to initialize, validate, build, preview, and clean the companion site.

Customize: CLI paths, output directory, local preview host, and the full ocg.config.json surface.

Landing Page

Home

The home page presents your project identity, navigation, source artifacts, ontology snapshot, configurable overview cards, featured terms, examples, and the raw artifact viewer.

Customize: site.hero, site.resourcePanel, site.overviewCards, site.customSections, and curation.featuredTerms.

Source Package

Artifacts and Viewer

OWL Ontology, SHACL, ShEx, specification, examples, and additional configured source files are copied into site/assets/. Config, schema, workflow, and guide files are available as generated links but are not raw-viewer tabs.

Customize: sources, features.rawViewer, and curation.viewerTabs.

Generated Page

Vocabulary Reference

The reference page extracts declared terms from the configured ontology and groups them by class, property, concept, and declared-term type.

Enable or disable: features.referencePage.

Interactive Page

Ontology Graph

The Ontology Network supports Predicates as Nodes or Predicates as Edges, plus filters, search, selection, layout, and external-term visibility. Its full-screen view gives the network the full viewport and provides a collapsible controls drawer. WebVOWL can be enabled alongside it and expanded the same way.

Customize: graph.custom, graph.webvowl, and graph.colors.

Generated Pages

Term Pages

Every declared ontology term can receive an individual page with its IRI, labels, types, source links, and incoming/outgoing relationships.

Enable or disable: features.termPages.

Optional Page

ReSpec Specification

Place a ReSpec HTML document at sources.spec. OCG publishes it at spec/index.html, injects the companion navigation, and links it from the site.

Enable or disable: features.specPage.

Site Foundation

Project Identity

Project metadata supplies the shared title, namespace, version, and maintainer information used throughout the site.

Optional Page

Usage Guide

The in-app guide can be enabled or disabled as a generated page and navigation destination.

Shared Styling

Theme and Footer

Theme colors, fonts, footer copy, and OCG repository/documentation links are configured here.

Developer Workflow

Package and CLI

Installs OCG into an existing ontology repository and controls initialization, validation, generation, cleanup, and local preview.

OptionDescription
npm install --save-dev ontology-companion-generatorInstalls the OCG CLI and its RDF, Sigma.js, and Graphology runtime dependencies.
Node.js 22.19+Supported runtime floor for OCG; generated GitHub Actions workflows use Node.js 24.
ocg init --ontology pathCreates an initial config, schema, Pages workflow, and npm scripts; namespace and common companion files are inferred when possible.
ocg init --forceReplaces the generated ocg.config.json while preserving an existing schema and workflow.
ocg checkValidates configuration, source paths, dependency assets, and ontology parsing without writing site output.
ocg buildGenerates the static site and vendors Sigma.js and Graphology browser bundles into site/assets/vendor/.
ocg devBuilds the site and serves it locally at http://127.0.0.1:4173/.
ocg cleanRemoves the generated site directory.
--config pathUses an alternate configuration file relative to the repository root.
--output pathWrites generated output to an alternate directory instead of site/.
--host host / --port portChanges the host or port used by the local ocg dev server.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "scripts": {
    "ocg:check": "ocg check",
    "ocg:build": "ocg build",
    "ocg:dev": "ocg dev",
    "ocg:clean": "ocg clean"
  },
  "commands": [
    "npm install --save-dev ontology-companion-generator",
    "npx ocg init --ontology vocab/my-vocabulary.ttl",
    "npm run ocg:check",
    "npm run ocg:build"
  ]
}
Site Foundation

Project Identity

Metadata used by the header, home page, generated titles, term pages, and graph data.

OptionDescription
$schemaOptional editor hint that points ocg.config.json to the bundled JSON Schema.
project.titleFull vocabulary name shown in page titles and the site header.
project.shortNameShort label used in the brand mark and compact headers.
project.slugStable project identifier stored in the generated graph metadata.
project.descriptionDefault project summary used when page-specific copy is not supplied.
project.namespaceNamespace IRI used to identify the vocabulary and copy from the home page.
project.canonicalUriCanonical vocabulary IRI shown in the ontology snapshot.
project.versionOptional vocabulary version shown in the ontology snapshot.
project.maintainerOptional maintainer shown in the ontology snapshot.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "title": "Your Vocabulary",
  "shortName": "YV",
  "slug": "your-vocabulary",
  "description": "What this vocabulary describes.",
  "namespace": "https://example.org/vocab#",
  "canonicalUri": "https://example.org/vocab",
  "version": "1.0.0",
  "maintainer": "Vocabulary Team"
}
Landing Page

Home

Controls all editorial landing-page copy and labels, including the repository-workflow heading, source controls, metadata, cards, featured terms, examples, and viewer.

OptionDescription
features.overviewCardsSet to false to hide the configurable overview-card row.
site.hero.kickerSmall eyebrow text above the home-page headline.
site.hero.headlineMain home-page headline; falls back to project.title when empty.
site.hero.bodyIntroductory home-page paragraph; falls back to project.description when empty.
site.resourcePanel.titleHeading for the published-artifacts panel.
site.resourcePanel.bodySupporting text for the published-artifacts panel.
site.home.actionsLabels for the Reference, Graph, Terms, Specification, OWL Ontology, SHACL, and ShEx actions. Set reference, graph, terms, specification, ontology, shapes, and shex.
site.home.metadataHome metadata labels and namespace-copy status messages. Set canonicalUri, version, maintainer, unspecified, copyNamespace, namespaceCopied, and namespaceCopyUnavailable.
site.home.snapshot.titleHeading above the ontology-derived metric cards.
site.home.snapshot.bodySupporting copy above the ontology-derived metric cards.
site.home.overview.titleHeading above site.overviewCards. Use this to replace Repository Workflow with vocabulary-specific guidance.
site.home.overview.bodySupporting copy above site.overviewCards.
site.home.featuredTerms.titleHeading for the featured ontology terms section.
site.home.featuredTerms.bodySupporting copy for the featured ontology terms section.
site.home.featuredTerms.emptyBodyMessage displayed when there are no explicit or automatically selected featured terms.
site.home.examples.titleHeading for the configured example-files section.
site.home.examples.bodySupporting copy for the configured example-files section.
site.home.examples.defaultDescriptionFallback description for an example without sources.examples[].description.
site.home.examples.linkTextAction label for each example card.
site.home.viewer.titleHeading for the raw source viewer.
site.home.viewer.bodySupporting copy for the raw source viewer.
site.home.viewer.viewFileTextAction label linking to the selected raw source file.
site.home.viewer.loadingTextTemporary message displayed while the selected source file loads.
site.home.artifactsFallback labels and descriptions for built-in ontology, SHACL, ShEx, and specification source assets. Set ontologyLabel/Description, shapesLabel/Description, shexLabel/Description, specificationLabel/Description, and additionalArtifactDescription.
site.overviewCards[].titleHeading for a configurable home-page card.
site.overviewCards[].bodyDescription shown inside a configurable home-page card.
site.overviewCards[].linkTextOptional label for the card link.
site.overviewCards[].linkHrefOptional relative or absolute destination for the card link.
site.customSections[].titleHeading for an additional home-page section.
site.customSections[].bodyParagraph displayed in an additional home-page section.
site.customSections[].itemsOptional list of supporting points displayed in that section.
curation.featuredTermsOptional array of ontology qnames to feature on the home page. When empty, OCG selects terms automatically.
curation.autoFeaturedTermsSet to false to hide automatic featured terms when no explicit featuredTerms are configured.
curation.featuredTermLimitMaximum number of terms selected automatically when featuredTerms is empty.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "features": {
    "overviewCards": true
  },
  "site": {
    "hero": {
      "kicker": "Forkable Vocabulary Template",
      "headline": "Explore Your Vocabulary",
      "body": "A short introduction shown on the home page."
    },
    "resourcePanel": {
      "title": "Published Artifacts",
      "body": "A short explanation shown above the artifact links."
    },
    "home": {
      "actions": {
        "reference": "Reference",
        "graph": "Ontology Network",
        "terms": "Browse Terms",
        "specification": "Specification",
        "ontology": "Ontology Source",
        "shapes": "Validation Shapes",
        "shex": "ShEx Schema"
      },
      "metadata": {
        "canonicalUri": "Vocabulary IRI",
        "version": "Release",
        "maintainer": "Maintained by",
        "unspecified": "Not provided",
        "copyNamespace": "Copy vocabulary namespace",
        "namespaceCopied": "Vocabulary namespace copied",
        "namespaceCopyUnavailable": "Vocabulary namespace could not be copied"
      },
      "snapshot": {
        "title": "Vocabulary at a Glance",
        "body": "Counts are generated from the configured ontology source."
      },
      "overview": {
        "title": "Using This Vocabulary",
        "body": "Add project-specific guidance above the configurable overview cards."
      },
      "featuredTerms": {
        "title": "Key Terms",
        "body": "Highlight the concepts and properties visitors should understand first.",
        "emptyBody": "No key terms are selected yet."
      },
      "examples": {
        "title": "Example Data",
        "body": "Link to representative instance data or usage examples.",
        "defaultDescription": "A configured example for this vocabulary.",
        "linkText": "View Example"
      },
      "viewer": {
        "title": "Source Viewer",
        "body": "Choose source files and their order with curation.viewerTabs.",
        "viewFileText": "View Source",
        "loadingText": "Loading source..."
      },
      "artifacts": {
        "ontologyLabel": "Ontology Source",
        "ontologyDescription": "Primary ontology source published with the companion site.",
        "shapesLabel": "Validation Shapes",
        "shapesDescription": "Optional SHACL constraints package.",
        "shexLabel": "ShEx Schema",
        "shexDescription": "Optional ShEx schema file.",
        "specificationLabel": "Specification Source",
        "specificationDescription": "Source document for the optional ReSpec specification page.",
        "additionalArtifactDescription": "Additional configured source artifact."
      }
    },
    "overviewCards": [
      {
        "title": "Card Title",
        "body": "Card text shown on the home page.",
        "linkText": "Learn More",
        "linkHref": "usage-guide.html#home"
      }
    ],
    "customSections": [
      {
        "title": "Additional Context",
        "body": "A custom narrative section for domain-specific guidance.",
        "items": [
          "A supporting point",
          "Another supporting point"
        ]
      }
    ]
  },
  "curation": {
    "featuredTerms": [
      "yv:ImportantClass",
      "yv:importantProperty"
    ]
  }
}
Source Package

Artifacts and Viewer

Publishes configured source files into site/assets/ and controls which files appear in the raw artifact viewer. OCG does not scan arbitrary directories. Primary ontology support is limited to Turtle, RDF/XML, JSON-LD, and N-Triples; other ontology syntaxes are rejected.

OptionDescription
sources.ontologyRequired path to the primary OWL/RDF ontology source.
sources.ontologyFormatFormat override: auto, turtle, rdfxml, jsonld, or ntriples. Auto uses the file extension; use an override for ambiguous extensions. TriG, N-Quads, N3, OWL Functional/Manchester/XML, OBO, arbitrary JSON/XML/YAML, CSV, and schema formats are not accepted.
sources.shapesOptional path to a SHACL shapes file.
sources.shexOptional path to a ShEx schema file.
sources.specOptional source document for the ReSpec Specification page; it is also copied as a viewer artifact.
sources.examples[].keyStable key used by viewerTabs to select an example.
sources.examples[].labelHuman-readable example label shown in the artifact list and viewer.
sources.examples[].pathPath to the example RDF or data file.
sources.examples[].descriptionOptional explanation shown with the example artifact.
sources.artifacts[].keyStable key used as artifact:<key> in viewerTabs.
sources.artifacts[].labelHuman-readable label shown in the artifact viewer.
sources.artifacts[].pathPath to any additional source file to copy into site/assets/.
sources.artifacts[].descriptionOptional explanation shown with the additional artifact.
sources.artifacts[].destinationNameOptional filename for the copied artifact; defaults to the source filename.
features.rawViewerSet to false to remove the raw artifact viewer from the home page.
features.hierarchyAssetSet to false to omit the generated ontology_hierarchy.ttl asset.
curation.viewerTabsOrdered source-asset keys to show in the raw viewer. Leave empty to show all source assets, or list keys such as ontology or artifact:context to curate the tabs. Config, schema, workflow, and guide assets are not viewer tabs.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "sources": {
    "ontology": "source/ontology/your-vocabulary.ttl",
    "shapes": "source/shapes/your-vocabulary.shacl.ttl",
    "shex": "source/shex/your-vocabulary.shex",
    "spec": "source/spec/index.html",
    "artifacts": [
      {
        "key": "context",
        "label": "Context JSON",
        "path": "source/context.json",
        "description": "Additional source documentation or metadata.",
        "destinationName": "context.json"
      }
    ],
    "examples": [
      {
        "key": "basic",
        "label": "Basic Example",
        "path": "source/examples/basic.ttl",
        "description": "A small valid instance graph."
      }
    ]
  },
  "features": {
    "rawViewer": true,
    "hierarchyAsset": true
  },
  "curation": {
    "viewerTabs": []
  }
}
Generated Page

Vocabulary Reference

Generates a browsable reference page from terms declared in the configured ontology, with an optional curated hierarchy overview above the Classes section.

OptionDescription
features.referencePageSet to false to omit ontology-reference.html and its navigation link.
features.hierarchyOverviewSet to true to show the generated hierarchy summary above the Classes section.
hierarchy.titleHeading for the hierarchy overview.
hierarchy.descriptionSupporting explanation shown below the hierarchy heading.
hierarchy.termTypesTerm types eligible for hierarchy branches. Defaults to class and concept; objectProperty, datatypeProperty, annotationProperty, and declaredTerm can be added when useful.
hierarchy.relationsHierarchy predicates to follow: subClassOf and/or broader.
hierarchy.rootTermsOptional qnames, IRIs, or local names to use as the major roots. Empty means OCG infers roots.
hierarchy.maxRootsMaximum number of major branches shown.
hierarchy.maxDepthMaximum number of levels below each root.
hierarchy.maxChildrenPerNodeMaximum representative child terms shown for each branch.
hierarchy.maxNodesGlobal cap on terms shown in the overview.
hierarchy.includeLeafTermsWhether leaf terms are retained. Set false to emphasize only branching structure.
hierarchy.includeExternalWhether external hierarchy terms may appear in the tree.
hierarchy.includePropertyRelationsWhether a capped list of important domain/range links is shown beside the tree.
hierarchy.propertyRelationsProperty relationship types to summarize: domain and/or range.
hierarchy.maxPropertyRelationsMaximum number of structural links shown beside the tree.
hierarchy.labelModeTerm display: label, qname, or label-and-qname.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "features": {
    "referencePage": true,
    "hierarchyOverview": true
  },
  "hierarchy": {
    "title": "Ontology Structure",
    "description": "A curated overview of the main class and concept relationships.",
    "termTypes": [
      "class",
      "concept"
    ],
    "relations": [
      "subClassOf",
      "broader"
    ],
    "rootTerms": [],
    "maxRoots": 6,
    "maxDepth": 3,
    "maxChildrenPerNode": 6,
    "maxNodes": 36,
    "includeLeafTerms": true,
    "includeExternal": false,
    "includePropertyRelations": true,
    "propertyRelations": [
      "domain",
      "range"
    ],
    "maxPropertyRelations": 12,
    "labelMode": "label-and-qname"
  }
}
Interactive Page

Ontology Graph

Configures the Sigma.js Ontology Network, its ForceAtlas2 and overlap-removal layout, adaptive labels, predicate modes, interactions, WebVOWL, and graph colors.

OptionDescription
features.graphPageSet to false to omit ontology-graph.html and its navigation link.
graph.defaultViewInitial representation: custom (displayed as Ontology Network by default) or webvowl. The selected representation must be enabled.
graph.custom.enabledEnables the generated Sigma.js graph.
graph.custom.labelLabel used for the generated Sigma.js representation in graph tabs and accessibility text.
graph.custom.defaultModeInitial custom mode: predicate-nodes or predicate-edges.
graph.custom.modes.predicateNodesEnables predicates as visible nodes, matching the VORD-style representation.
graph.custom.modes.predicateEdgesEnables predicates as labeled edges between domain and range nodes.
graph.custom.layout.iterationsBase ForceAtlas2 iteration count. OCG scales it by component size; increase it for difficult dense graphs.
graph.custom.layout.seedDeterministic integer seed used for stable initial positions across builds.
graph.custom.layout.scalingRatioMultiplier applied to Graphology's inferred ForceAtlas2 scaling. Higher values spread connected nodes farther apart.
graph.custom.layout.gravityForceAtlas2 gravity keeping each connected component compact.
graph.custom.layout.linLogModeUses ForceAtlas2 LinLog attraction to emphasize clusters; leave false for a more even ontology network.
graph.custom.layout.preventOverlapRuns Graphology Noverlap after ForceAtlas2 using label-aware collision sizes.
graph.custom.layout.labelSpacingMultiplier for label collision spacing and component bounds.
graph.custom.labels.densitySigma label density for large graphs where every label is not forced.
graph.custom.labels.gridCellSizeSigma label-collision grid cell size in screen pixels.
graph.custom.labels.renderedSizeThresholdMinimum rendered node size before a non-forced label can appear.
graph.custom.labels.forceAllUnderFor graphs at or below this node count, force every visible label. Larger graphs prioritize connected terms and reveal more labels when zoomed or selected.
graph.webvowl.enabledEnables the WebVOWL representation toggle.
graph.webvowl.serviceUrlWebVOWL service URL loaded by the graph iframe.
graph.webvowl.ontologyUrlOptional public URL of the serialized ontology document; leave empty to derive the deployed asset URL. Do not use project.namespace or a URL ending in #.
graph.webvowl.heightIframe height in pixels; minimum value is 320.
graph.colors.classFill color for class nodes.
graph.colors.objectPropertyFill color for object-property nodes.
graph.colors.datatypePropertyFill color for datatype-property nodes.
graph.colors.annotationPropertyFill color for annotation-property nodes.
graph.colors.conceptFill color for SKOS concept nodes.
graph.colors.declaredTermFill color for other declared-term nodes.
graph.colors.externalFill color for external reference nodes.
graph.colors.subClassOfEdge color for subclass relationships.
graph.colors.domainEdge color for domain relationships.
graph.colors.rangeEdge color for range relationships.
graph.colors.broaderEdge color for broader/concept hierarchy relationships.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "defaultView": "custom",
  "custom": {
    "enabled": true,
    "label": "Ontology Network",
    "defaultMode": "predicate-nodes",
    "modes": {
      "predicateNodes": true,
      "predicateEdges": true
    },
    "layout": {
      "iterations": 320,
      "seed": 42,
      "scalingRatio": 1.4,
      "gravity": 1,
      "linLogMode": false,
      "preventOverlap": true,
      "labelSpacing": 1.15
    },
    "labels": {
      "density": 1.5,
      "gridCellSize": 90,
      "renderedSizeThreshold": 2,
      "forceAllUnder": 80
    }
  },
  "webvowl": {
    "enabled": true,
    "serviceUrl": "https://service.tib.eu/webvowl/",
    "ontologyUrl": "",
    "height": 760
  },
  "colors": {
    "class": "#b7dcf6",
    "objectProperty": "#bee7c3",
    "datatypeProperty": "#f7d7ab",
    "annotationProperty": "#f2c8cf",
    "concept": "#d3c5f6",
    "declaredTerm": "#e1e8ef",
    "external": "#dfe6ee",
    "subClassOf": "#1f6f92",
    "domain": "#2f8040",
    "range": "#ab6b22",
    "broader": "#7b5ca7"
  }
}
Generated Pages

Term Pages

Creates one HTML page for each declared ontology term, with relationships and source links.

OptionDescription
features.termPagesSet to false to omit the terms directory and its navigation link.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "features": {
    "termPages": true
  }
}
Optional Page

ReSpec Specification

Publishes a source ReSpec document as a first-class companion page with injected navigation.

OptionDescription
features.specPageSet to true to generate spec/index.html and its navigation link.
sources.specPath to the ReSpec HTML source; required when specPage is enabled.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "sources": {
    "spec": "source/spec/index.html"
  },
  "features": {
    "specPage": true
  }
}
Optional Page

Usage Guide

Generates this in-app configuration and workflow guide with component-specific How To links.

OptionDescription
features.usageGuidePageSet to false to omit usage-guide.html, its navigation link, and all How To links.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "features": {
    "usageGuidePage": true
  }
}
Shared Styling

Theme, Page Navigation, Footer, and Generator Links

Applies site-wide branding images, fonts, colors, page table-of-contents behavior, footer copy, and OCG attribution links.

OptionDescription
site.basePathDeployment base-path setting retained for repository configuration; generated links are currently relative.
site.branding.headerImageOptional repository-relative image shown in place of project.shortName inside the square header mark on every companion page and the ReSpec navigation. Supported: .png, .jpg, .jpeg, .webp, .gif, and .svg.
site.branding.faviconOptional repository-relative browser favicon. Supported: .ico, .png, and .svg. When omitted, OCG keeps the source/branding/favicon.png and favicon.ico fallback behavior.
theme.fonts.headingFont family for headings and brand text.
theme.fonts.bodyFont family for body copy and interface text.
theme.fonts.monoFont family for code, IRIs, and source content.
theme.colors.pageBackgroundMain page background color.
theme.colors.pageBackgroundAltSecondary page background color used by the layered background.
theme.colors.panelBackgroundBase panel background color.
theme.colors.cardBackgroundBase card background color.
theme.colors.textPrimary text and heading color.
theme.colors.mutedTextSecondary text color.
theme.colors.accentPrimary link and accent color.
theme.colors.accentStartStarting color for accent gradients and branded controls.
theme.colors.accentBorderBorder color for primary accent controls.
theme.colors.accentStrongStrong accent color for active and emphasized controls.
theme.colors.borderShared border color.
theme.colors.warmAccentWarm accent used by the page background glow and supporting highlights.
site.toc.enabledSet to false to remove the contextual table of contents from Home, Reference, Terms, and term-detail pages.
site.toc.titleHeading for the contextual table of contents. It is shown only when a page has multiple sections.
site.toc.collapseLabelAccessible label and tooltip for the control that collapses the TOC rail and expands the page content.
site.toc.expandLabelAccessible label and tooltip for the control that restores the expanded TOC rail.
site.footer.primaryPrimary footer sentence.
site.footer.secondarySecondary footer sentence.
site.generator.repositoryUrlOptional link to the OCG repository in the generated footer.
site.generator.documentationUrlOptional link to OCG documentation in the generated footer.

Example

This example includes every option described in this component section. Remove optional entries you do not need.

{
  "site": {
    "basePath": "/",
    "branding": {
      "headerImage": "source/branding/vocabulary-logo.svg",
      "favicon": "source/branding/vocabulary-favicon.svg"
    },
    "toc": {
      "enabled": true,
      "title": "On this page",
      "collapseLabel": "Collapse page contents",
      "expandLabel": "Expand page contents"
    },
    "footer": {
      "primary": "Your vocabulary companion site.",
      "secondary": "Maintained by the Vocabulary Team."
    },
    "generator": {
      "repositoryUrl": "https://github.com/ecrum19/ocg",
      "documentationUrl": "https://github.com/ecrum19/ocg#readme"
    }
  },
  "theme": {
    "fonts": {
      "heading": "Space Grotesk",
      "body": "IBM Plex Sans",
      "mono": "IBM Plex Mono"
    },
    "colors": {
      "pageBackground": "#f6f1ea",
      "pageBackgroundAlt": "#edf3f7",
      "panelBackground": "#ffffff",
      "cardBackground": "#ffffff",
      "text": "#1d1f22",
      "mutedText": "#5f6b7a",
      "accent": "#1f6f78",
      "accentStart": "#248992",
      "accentBorder": "#1c7d86",
      "accentStrong": "#13535a",
      "border": "#d6dee6",
      "warmAccent": "#e1ab4e"
    }
  }
}

Complete Configuration Example

The config is the primary customization surface. The schema file provides editor validation.

{
  "$schema": "./ocg.config.schema.json",
  "project": {
    "title": "Your Vocabulary",
    "shortName": "YV",
    "slug": "your-vocabulary",
    "description": "What this vocabulary describes.",
    "namespace": "https://example.org/vocab#",
    "canonicalUri": "https://example.org/vocab",
    "version": "1.0.0",
    "maintainer": "Vocabulary Team"
  },
  "sources": {
    "ontology": "source/ontology/your-vocabulary.ttl",
    "ontologyFormat": "auto",
    "shapes": "source/shapes/your-vocabulary.shacl.ttl",
    "shex": "source/shex/your-vocabulary.shex",
    "spec": "source/spec/index.html",
    "examples": [
      {
        "key": "basic",
        "label": "Basic Example",
        "path": "source/examples/basic.ttl",
        "description": "A small valid instance graph."
      }
    ],
    "artifacts": [
      {
        "key": "context",
        "label": "Context JSON",
        "path": "source/context.json",
        "description": "Additional source documentation or metadata.",
        "destinationName": "context.json"
      }
    ]
  },
  "features": {
    "referencePage": true,
    "graphPage": true,
    "termPages": true,
    "rawViewer": true,
    "overviewCards": true,
    "hierarchyAsset": true,
    "hierarchyOverview": true,
    "specPage": true,
    "usageGuidePage": true
  },
  "hierarchy": {
    "title": "Ontology Structure",
    "description": "A curated overview of the main class and concept relationships.",
    "termTypes": [
      "class",
      "concept"
    ],
    "relations": [
      "subClassOf",
      "broader"
    ],
    "rootTerms": [],
    "maxRoots": 6,
    "maxDepth": 3,
    "maxChildrenPerNode": 6,
    "maxNodes": 36,
    "includeLeafTerms": true,
    "includeExternal": false,
    "includePropertyRelations": true,
    "propertyRelations": [
      "domain",
      "range"
    ],
    "maxPropertyRelations": 12,
    "labelMode": "label-and-qname"
  },
  "graph": {
    "defaultView": "custom",
    "custom": {
      "enabled": true,
      "label": "Ontology Network",
      "defaultMode": "predicate-nodes",
      "modes": {
        "predicateNodes": true,
        "predicateEdges": true
      },
      "layout": {
        "iterations": 320,
        "seed": 42,
        "scalingRatio": 1.4,
        "gravity": 1,
        "linLogMode": false,
        "preventOverlap": true,
        "labelSpacing": 1.15
      },
      "labels": {
        "density": 1.5,
        "gridCellSize": 90,
        "renderedSizeThreshold": 2,
        "forceAllUnder": 80
      }
    },
    "webvowl": {
      "enabled": true,
      "serviceUrl": "https://service.tib.eu/webvowl/",
      "ontologyUrl": "",
      "height": 760
    },
    "colors": {
      "class": "#b7dcf6",
      "objectProperty": "#bee7c3",
      "datatypeProperty": "#f7d7ab",
      "annotationProperty": "#f2c8cf",
      "concept": "#d3c5f6",
      "declaredTerm": "#e1e8ef",
      "external": "#dfe6ee",
      "subClassOf": "#1f6f92",
      "domain": "#2f8040",
      "range": "#ab6b22",
      "broader": "#7b5ca7"
    }
  },
  "theme": {
    "fonts": {
      "heading": "Space Grotesk",
      "body": "IBM Plex Sans",
      "mono": "IBM Plex Mono"
    },
    "colors": {
      "pageBackground": "#f6f1ea",
      "pageBackgroundAlt": "#edf3f7",
      "panelBackground": "#ffffff",
      "cardBackground": "#ffffff",
      "text": "#1d1f22",
      "mutedText": "#5f6b7a",
      "accent": "#1f6f78",
      "accentStart": "#248992",
      "accentBorder": "#1c7d86",
      "accentStrong": "#13535a",
      "border": "#d6dee6",
      "warmAccent": "#e1ab4e"
    }
  },
  "site": {
    "basePath": "/",
    "branding": {
      "headerImage": "source/branding/vocabulary-logo.svg",
      "favicon": "source/branding/vocabulary-favicon.svg"
    },
    "hero": {
      "kicker": "Forkable Vocabulary Template",
      "headline": "Explore Your Vocabulary",
      "body": "A short introduction shown on the home page."
    },
    "resourcePanel": {
      "title": "Published Artifacts",
      "body": "A short explanation shown above the artifact links."
    },
    "toc": {
      "enabled": true,
      "title": "On this page",
      "collapseLabel": "Collapse page contents",
      "expandLabel": "Expand page contents"
    },
    "home": {
      "actions": {
        "reference": "Reference",
        "graph": "Ontology Network",
        "terms": "Browse Terms",
        "specification": "Specification",
        "ontology": "Ontology Source",
        "shapes": "Validation Shapes",
        "shex": "ShEx Schema"
      },
      "metadata": {
        "canonicalUri": "Vocabulary IRI",
        "version": "Release",
        "maintainer": "Maintained by",
        "unspecified": "Not provided",
        "copyNamespace": "Copy vocabulary namespace",
        "namespaceCopied": "Vocabulary namespace copied",
        "namespaceCopyUnavailable": "Vocabulary namespace could not be copied"
      },
      "snapshot": {
        "title": "Vocabulary at a Glance",
        "body": "Counts are generated from the configured ontology source."
      },
      "overview": {
        "title": "Using This Vocabulary",
        "body": "Add project-specific guidance above the configurable overview cards."
      },
      "featuredTerms": {
        "title": "Key Terms",
        "body": "Highlight the concepts and properties visitors should understand first.",
        "emptyBody": "No key terms are selected yet."
      },
      "examples": {
        "title": "Example Data",
        "body": "Link to representative instance data or usage examples.",
        "defaultDescription": "A configured example for this vocabulary.",
        "linkText": "View Example"
      },
      "viewer": {
        "title": "Source Viewer",
        "body": "Choose source files and their order with curation.viewerTabs.",
        "viewFileText": "View Source",
        "loadingText": "Loading source..."
      },
      "artifacts": {
        "ontologyLabel": "Ontology Source",
        "ontologyDescription": "Primary ontology source published with the companion site.",
        "shapesLabel": "Validation Shapes",
        "shapesDescription": "Optional SHACL constraints package.",
        "shexLabel": "ShEx Schema",
        "shexDescription": "Optional ShEx schema file.",
        "specificationLabel": "Specification Source",
        "specificationDescription": "Source document for the optional ReSpec specification page.",
        "additionalArtifactDescription": "Additional configured source artifact."
      }
    },
    "overviewCards": [
      {
        "title": "Card Title",
        "body": "Card text shown on the home page.",
        "linkText": "Learn More",
        "linkHref": "usage-guide.html#home"
      }
    ],
    "customSections": [
      {
        "title": "Additional Context",
        "body": "A custom narrative section for domain-specific guidance.",
        "items": [
          "A supporting point",
          "Another supporting point"
        ]
      }
    ],
    "footer": {
      "primary": "Your vocabulary companion site.",
      "secondary": "Maintained by the Vocabulary Team."
    },
    "generator": {
      "repositoryUrl": "https://github.com/ecrum19/ocg",
      "documentationUrl": "https://github.com/ecrum19/ocg#readme"
    }
  },
  "curation": {
    "featuredTerms": [
      "yv:ImportantClass",
      "yv:importantProperty"
    ],
    "autoFeaturedTerms": true,
    "featuredTermLimit": 6,
    "viewerTabs": []
  }
}

GitHub Pages Deployment

The included workflow builds the ontology repository on pushes to main and deploys the generated site/ directory.

Required repository setting: in GitHub, open Settings → Pages and select GitHub Actions as the deployment source. The workflow intentionally deploys only main so feature branches cannot overwrite the live site.

GitHub Pages does not dynamically follow the branch currently selected in the GitHub file browser. Deploying every branch would send each build to the same Pages site, with the latest deployment replacing the previous one. Build and test feature branches locally or with build-only CI, then merge to main for publication.

Useful Commands

Run these from the repository root.

npm install --save-dev ontology-companion-generator
npx ocg init --ontology vocab/my-vocabulary.ttl
npm run ocg:check   # validate config and parse ontology
npm run ocg:build   # generate site/
npm run ocg:dev     # preview at http://127.0.0.1:4173/
npm run ocg:clean   # remove generated site/