Configuration
The Docs Engine is designed to allow customization by each Cloudflare product team.
Every docs site must include a docs-config.js
file. This file is used by Docs Engine to customize the docs site’s title, logo, external links menu, site metadata, search, and more.
Properties
Create a docs-config.js
file which exports (by setting module.exports
) a JavaScript object containing the following properties:
product
string
- The title of the project, e.g.
"My Docs"
. Displayed inside the sidebar navigation on desktop, the header on mobile, and concatenated into a few tooltips.
- The title of the project, e.g.
pathPrefix
string
- A proxy to the Gatsby property of the same name. Specifies a URL path prefix, e.g.
"/example"
, to deploy the site to. Specifying the empty string (""
) to deploy to the root. Development is done at the root (localhost:8000
) regardless of the value.
- A proxy to the Gatsby property of the same name. Specifies a URL path prefix, e.g.
productIconKey
string
- The logo for the docs site, specified as product icon found by key from @cloudflare/cloudflare-brand-assets. One of
productIconKey
orproductLogoPathD
is required.
- The logo for the docs site, specified as product icon found by key from @cloudflare/cloudflare-brand-assets. One of
productLogoPathD
string
- The logo for the docs site, specified directly as the SVG
<path/>
d
attribute for an inline SVG element withviewBox="0 0 48 48"
. The example"M8 8h32v32h-32v-32z"
would draw a solid32px
square centered inside the48px
square space. One ofproductLogoPathD
orproductIconKey
is required.
- The logo for the docs site, specified directly as the SVG
contentRepo
string
- The GitHub repo (e.g.
"cloudflare/cloudflare-docs"
) used to for example construct the the “Edit on GitHub” links displayed in each docs page’s footer.
- The GitHub repo (e.g.
contentRepoFolder
string
- By default the engine assumes that a docs site’s structure is placed in the root of a project repo. However, this whole structure can also be placed inside any sub-folder by setting this property. For example, this site’s content is inside the
products/docs-engine
folder of @cloudflare/cloudflare-docs so its"products/docs-engine"
.
- By default the engine assumes that a docs site’s structure is placed in the root of a project repo. However, this whole structure can also be placed inside any sub-folder by setting this property. For example, this site’s content is inside the
externalLinks
array
- An array of objects each specifying a
title
string
andurl
string
. Used to construct the external links menu inside the sidebar nav on desktop.
- An array of objects each specifying a
search
object
Adds a search to the site, powered by Algolia DocSearch. To hide search, set
search.indexName
andsearch.apiKey
to the empty string, andsearch.algoliaOptions
to the default empty filter, e.g.:search: {indexName: "",apiKey: "",algoliaOptions: { "facetFilters": "" }}For an example of a project using search, see the Workers config.
siteMetadata
object
A proxy to the Gatsby property of the same name. Sub-properties:
title
string
- Used in meta tags for SEO.
description
string
- Used in description meta tags for SEO.
author
string
- Used in author meta tags for SEO.
url
string
- The URL of the final resulting site (including appending
pathPrefix
). Used to constructrel="canonical"
meta tags for SEO.
- The URL of the final resulting site (including appending
image
string
- Used for the
og:image
meta tag for SEO and social media.
- Used for the
Examples
Here’s the docs-config.js
file for these docs:
docs-config.jsmodule.exports = { product: "Docs Engine", pathPrefix: "/docs-engine", productIconKey: "docs-engine", contentRepo: "cloudflare/cloudflare-docs", contentRepoFolder: "products/docs-engine", externalLinks: [ { title: "Docs Engine on GitHub", url: "https://github.com/cloudflare/cloudflare-docs-engine" }, { title: "Cloudflare Developer documentation", url: "https://developers.cloudflare.com/docs" }, ], search: { indexName: "", apiKey: "", }, siteMetadata: { title: "Cloudflare Docs Engine docs", description: "Documentation for the open-source Cloudflare Documentation engine which powers Cloudflare's open-source documentation.", author: "@cloudflare", url: "https://developers.cloudflare.com/docs-engine", image: "https://www.cloudflare.com/img/cf-twitter-card.png", }}
(Source)