Configuration
Overview
JS.SSG allows you to override most of the default settings by using a configuration file: config.json
The config.json
file should live in the root of your project, and is used to both reset default values and save global data about your site.
The contents of your config.json
could look something like this:
{
"in": "src/content",
"out": "dist",
"templates": "src/templates",
"data": {
"title": "JSSSG Docs",
"url": "https://jsssg.org/"
}
}
Configuration options
in
This is the path to your Markdown content files.
Default: "content"
out
This is where JS.SSG will save the final output for your site.
Default: "build"
appName
If defined, appName
will be prepended to the filename of your style files. For example, setting appName: "my-site"
will result in app.scss
becoming my-site.app.css
.
Default: false
templates
The path to your template files.
Default: "templates"
images
The path to your image files.
Default: "images"
public
The path to your public files.
Default: "public"
styles
The path to your Sass files. Every "root" Sass file (i.e. those not starting with an underscore) in this directory will be compiled to CSS and saved in the output folder. If you have a file called app.scss
in this directory, it will be compiled to app.css
in the output folder, but partials like _variables.scss
will not be compiled.
If you have set an appName
, the output file will be prepended with the name you've chosen.
Default: false
ignore
Markdown files that contain this in their path will not be processed by JS.SSG.
Default: "drafts"
collections
The taxonomies that JS.SSG will use when creating collections.
Default: ["categories", "tags"]
search
Boolean value that sets whether or not a search-data.json
file is created.
Default: true
searchFields
An array of the frontmatter fields that will be included in search-data.json
for each page (in addition to the main content).
Default: ["title"]
rss
Boolean value that sets whether or not a feed.xml
file is created.
Default: true
sitemap
Boolean value that sets whether or not a sitemap.xml
file is created.
Default: true
clean
Boolean value that sets whether or not the output folder (/build
by default) is deleted before building the new version.
Default: false
Global site data
The "data" section of config.json
is reserved for information about your site in general. This data is included in the site
object that gets passed to all page templates (along with the content
and page
values).
The only value included by defualt is "url"
. data.url
has a default value of "http://localhost:8080/"
(or whatever port you've specified in the command arguments) but you should set this to be the final URL where your site will live.
// config.json
{
"data": {
"title": "JS.SSG Docs",
"url": "http://jsssg.org/"
}
}
// templates/Page.jsx
const Page = ({ content, page, site }) => (
<html lang="en">
<head>
<title>{site.title}</title>
//...
</head>
//...
</html>
);
Unless you declare them, JS.SSG will assume you're using the default values for in
, out
, and templates
, so these are optional in your config.json
. data.title
and data.url
are required, however. title
is whatever you want to call your site, and url
should be the URL where your site will eventually live. Don't worry if you don't have a URL yet, you can put in anything here and change it later.
The data
object is where you can store any and all information about your site. This object will be accessible within all your templates as the site
prop.