Configuration Options

GTFS-to-HTML reads its configuration from a JSON file. To get started, copy config-sample.json to config.json and then add your project's configuration to config.json.

cp config-sample.json config.json

Ensure that your config.json is valid JSON before proceeding.

note

All files starting with config*.json are .gitignored - so you can create multiple configuration files such as config-caltrain.json.

optiontypedescription
agenciesarrayAn array of GTFS files to be imported.
beautifybooleanWhether or not to beautify the HTML output.
coordinatePrecisionintegerNumber of decimal places to include in geoJSON map output.
dataExpireAfterSecondsintegerThe number of seconds after which the data will be deleted from mongodb using a TTL index.
dateFormatstringA string defining date format in moment.js style.
dayShortStringsarray of stringsAn array defining contractions of weekdays names from Monday to Sunday.
dayStringsarray of stringsAn array defining weekdays names from Monday to Sunday.
defaultOrientationstringSpecifies timetable orientation, when not mentioned in timetables.txt
effectiveDatestringA date to print at the top of the timetable
interpolatedStopSymbolstringThe symbol used to indicate that a timepoint isn't fixed, but just interpolated.
interpolatedStopTextstringThe text used to describe a timepoint isn't fixed, but just interpolated.
linkStopUrlsbooleanWhether or not to hyperlink timetable stop names to the stop_url defined in stops.txt.
logFunctionfunctionA custom logging function for handling output of logs.
mapboxAccessTokenstringThe Mapbox access token for generating a map of the route.
menuTypestringThe type of menu to use for selecting timetables on a timetable page.
mongoUrlstringThe URL of the MongoDB database to import to.
noDropoffSymbolstringThe symbol used to indicate ta stop where no drop off is available.
noDropoffTextstringThe text used to describe a stop where no drop off is available.
noHeadbooleanWhether or not to skip the header and footer of the HTML document.
noServiceSymbolstringThe symbol used when a specific trip does not serve a specified stop.
noServiceTextstringThe text used to describe a stop which is not served by a specific trip.
outputFormatstringThe file format of the timetables generated. Either html or pdf.
noPickupSymbolstringThe symbol used to indicate a stop where no pickup is available.
noPickupTextstringThe text used to describe a stop where no pickup is available.
requestDropoffSymbolstringThe symbol used to indicate a stop where riders must request a drop off.
requestDropoffTextstringThe text used to describe a stop where riders must request a drop off.
requestPickupSymbolstringThe symbol used to indicate a stop where riders must request a pickup.
requestPickupTextstringThe text used to describe a stop where riders must request a pickup.
serviceNotProvidedOnTextstringThe text used to label days where service is not provided.
serviceProvidedOnTextstringThe text used to label days where service is provided.
showArrivalOnDifferencefloatDefines a difference between departure and arrival, on which arrival column/row will be shown.
showMapbooleanWhether or not to show a map of the route on the timetable.
showOnlyTimepointbooleanWhether or not all stops should be shown, or only stops with a timepoint value in stops.txt.
showRouteTitlebooleanWhether or not to show the route title at the top of the timetable page.
showStopCitybooleanWhether or not to show each stop's city.
showStopDescriptionbooleanWhether or not to show a stop description.
skipImportbooleanWhether or not to skip importing GTFS data into mongoDB.
sortingAlgorithmstringDefines the trip-sorting algorithm.
templatePathstringPath to custom pug template for rendering timetable.
timeFormatstringA string defining time format in moment.js style.
useParentStationbooleanWhether or not to use a stop's parent_station.
verbosebooleanWhether or not to print output to the console.
zipOutputbooleanWhether or not to zip the output into one zip file.

agencies

{Array} Specify the GTFS files to be imported in an agencies array. GTFS files can be imported via a url or a local path.

Each file needs an agency_key, a short name you create that is specific to that GTFS file. For GTFS files that contain more than one agency, you only need to list each GTFS file once in the agencies array, not once per agency that it contains.

To find an agency's GTFS file, visit transitfeeds.com. You can use the URL from the agency's website or you can use a URL generated from the transitfeeds.com API along with your API token.

  • Specify a download URL:
{
"agencies": [
{
"agency_key": "county-connection",
"url": "http://cccta.org/GTFS/google_transit.zip"
}
]
}
  • Specify a path to a zipped GTFS file:
{
"agencies": [
{
"agency_key": "myAgency",
"path": "/path/to/the/gtfs.zip"
}
]
}
  • Specify a path to an unzipped GTFS file:
{
"agencies": [
{
"agency_key": "myAgency",
"path": "/path/to/the/unzipped/gtfs/"
}
]
}
  • Exclude files - if you don't want all GTFS files to be imported, you can specify an array of files to exclude.
{
"agencies": [
{
"agency_key": "myAgency",
"path": "/path/to/the/unzipped/gtfs/",
"exclude": [
"shapes",
"stops"
]
}
]
}
  • Optionally specify a proj4 projection string to correct poorly formed coordinates in the GTFS file
{
"agencies": [
{
"agency_key": "myAgency",
"path": "/path/to/the/unzipped/gtfs/",
"proj": "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs"
}
]
}

beautify

{Boolean} Whether or not to beautify the HTML output. Defaults to false.

"beautify": false

coordinatePrecision

{Integer} The number of decimal places to include in the latitude and longitude of coordinates in GeoJSON used in maps. Omit to avoid any rounding. 5 is a reasonable value (about 1.1 meters).

"coordinatePrecision": 5

dataExpireAfterSeconds

{Integer} The number of seconds after which the data will be deleted from mongodb using a TTL index. Optional, if not specified then data will not be automatically deleted.

"dataExpireAfterSeconds": 3600

dateFormat

{String} A string defining date format in moment.js manner. Change it, when you want to customize date format shown in timetables

"dateFormat": "MMM D, YYYY"

daysShortStrings

{Array [String]} An array of strings defining contractions of weekday names. Specify from Monday to Sunday.

"daysShortStrings": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

daysStrings

{Array [String]} An array of strings defining contractions of weekday names. Specify from Monday to Sunday.

"daysStrings": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

defaultOrientation

{String} Specifies timetable orientation, when not mentioned in timetables.txt. For options see timetables.txt specification

"defaultOrientation": "vertical"

effectiveDate

{String} This is printed at the top of the timetable.

"effectiveDate": "July 8, 2015"

interpolatedStopSymbol

{String} The symbol used to indicate that a timepoint isn't fixed, but just interpolated. Defaults to . To avoid having this symbol used in timetables, set it to null.

"interpolatedStopSymbol": "•"

interpolatedStopText

{String} The text used to describe that a timepoint isn't fixed, but just interpolated. Defaults to Estimated time of arrival.

"interpolatedStopText": "Estimated time of arrival"

linkStopUrls

{Boolean} Whether or not to hyperlink timetable stop names to the stop_url defined in stops.txt. If no stop_url is defined for a stop, no link will be created. Defaults to false.

"linkStopUrls": false

logFunction

{Function} If you want to route logs to a custom function, you can pass a function that takes a single text argument as logFunction. This can't be used when running GTFS-to-HTML as a command-line utility, only when included as part of a node.js app and passed in a config object to gtfsToHtml(). For example:

const gtfsToHTML = require('gtfs-to-html');
const mongoose = require('mongoose');
const config = {
mongoUrl: 'mongodb://localhost:27017/gtfs',
agencies: [
{
agency_key: 'county-connection',
url: 'http://countyconnection.com/GTFS/google_transit.zip',
exclude: [
'shapes'
]
}
],
logFunction: function(text) {
// Do something with the logs here, like save it or send it somewhere
console.log(text);
}
};
mongoose.connect(config.mongoUrl, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true });
gtfsToHTML(config);

mapboxAccessToken

{String} The Mapbox access token for generating a map of the route.

"mapboxAccessToken": "pk.eyXaX5F8oCJSYedim3yCnTGsVBfnRjsoXdy4Ej7ZZZydrCn2WMDXha5bPj5.bPj5xsBo8u8N8GJqJh"

menuType

{String} The type of menu to use for selecting or navigating to timetables on timetable pages with multiple timetables. Valid choices are none, simple, jump and radio. Defaults to simple.

"menuType": "jump"

mongoUrl

{String} The MongoDB URI use. When running locally, you may want to use mongodb://localhost:27017/gtfs.

{
"mongoUrl": "mongodb://localhost:27017/gtfs",
"agencies": [
{
"agency_key": "myAgency",
"path": "/path/to/the/unzipped/gtfs/"
}
]
}

noDropoffSymbol

{String} The symbol used to indicate that no drop off is available at a stop. Defaults to . To avoid having this symbol used in timetables, set it to null.

"noDropoffSymbol": "‡"

noDropoffText

{String} The text used to describe that no drop off is available at a stop. Defaults to No drop off available.

"noDropoffText": "No drop off available"

noHead

{Boolean} Whether or not to skip the HTML head and footer when generating the HTML. This is useful for creating embeddable HTML without <html>, <head> or <body> tags. Defaults to false. Ignored if outputFormat is set to pdf.

"noHead": false

noPickupSymbol

{String} The symbol used to indicate that no pickup is available at a stop. Defaults to **. To avoid having this symbol used in timetables, set it to null.

"noPickupSymbol": "**"

noPickupText

{String} The text used to describe that no pickup is available at a stop. Defaults to No pickup available.

"noPickupText": "No pickup available"

noServiceSymbol

{String} The symbol used when a specific trip does not serve a specified stop. Defaults to -. To avoid having this symbol used in timetables, set it to null.

"noServiceSymbol": "-"

noServiceText

{String} The text used to describe when a specific trip does not serve a specified stop. Defaults to No service at this stop.

"noServiceText": "No service at this stop"

outputFormat

{String} The file format of the timetables generated. Either html or pdf. Defaults to html.

"outputFormat": "html"

requestDropoffSymbol

{String} The symbol used to indicate that riders must request to be dropped off at a stop. Defaults to . To avoid having this symbol used in timetables, set it to null.

"requestDropoffSymbol": "†"

requestDropoffText

{String} The text used to describe that riders must request to be dropped off at a stop. Defaults to Must request drop off.

"requestDropoffText": "Must request drop off"

requestPickupSymbol

{String} The symbol used to indicate that riders must request pickup at a stop. Defaults to ***. To avoid having this symbol used in timetables, set it to null.

"requestPickupSymbol": "***"

requestPickupText

{String} The text used to describe that riders must request pickup at a stop. Defaults to Request stop - call for pickup.

"requestPickupText": "Request stop - call for pickup"

serviceNotProvidedOnText

{String} The text used to label days where service is not provided. Defaults to Service not provided on.

"serviceNotProvidedOnText": "Service not provided on"

serviceProvidedOnText

{String} The text used to label days where service is provided. Defaults to Service provided on.

"serviceProvidedOnText": "Service provided on"

showArrivalOnDifference

{Float} Whether or not to show an arrival column/row in the timetable. It means, that if on at least one stop difference (stay on that stop) is equal or greater than specified here, the arrival time will be shown. Use 0 to show on each stop or null to supress for showing arrival at all.

"showArrivalOnDifference": 0.2

showMap

{Boolean} Whether or not to show a map of the route on the timetable. Defaults to false.

If you'd rather just get all stops and route info as geoJSON, see gtfs-to-geojson.

"showMap": false

showOnlyTimepoint

{Boolean} Whether or not all stops should be shown, or only stops with a timepoint value in stop_times.txt that is considered exact (i.e. empty or 1). Defaults to false, all stops shown.

"showOnlyTimepoint": false

showRouteTitle

{Boolean} Whether or not to show the route title at the top of the timetable page. Defaults to true, showing the route title.

"showRouteTitle": true

showStopCity

{Boolean} Whether or not to show the city for each stop. City is determined by the stop_city field in the non-standard stop_attributes.txt. Only has an effect when the timetable's orientation is horizontal or hourly. Defaults to false.

"showStopCity": false

showStopDescription

{Boolean} Whether or not to show a stop description for each stop. Stop description is taken from the stop_desc field instops.txt. Defaults to false.

"showStopDescription": false

skipImport

{Boolean} Whether or not to skip importing from GTFS into mongoDB. Useful for re-running the script if the GTFS data has not changed. Defaults to false.

"skipImport": false

sortingAlgorithm

{String} Defines trip-sorting algorithm. There are two main groups of algorithms: simplified and full.

Simplified algorithms sort trips by using one specific stop.

  • common finds a coommon stop (used by all trips) (if not found first is used).
  • first uses the first stop stop on the longest trip
  • last uses the last stop on the longest trip

Full algorithms sorting usinig every stop on the route. If there is no time specified, the trip will remain in its previous place.

  • beginning sorts from beginning to end
  • end sorts from end to beginning

The default trip-sorting algorithm is common.

"sortingAlgorithm": "common"

dateFormat

{String} A string defining time format in moment.js manner. Change it, when you want to customize time format shown in timetables.

"timeFormat": "h:mma"

templatePath

{String} Path to a folder containing (pug)[https://pugjs.org/] template for rendering timetables. This is optional. Defaults to using the templates provided in views/timetable. All files within the /views/custom folder will be .gitignored, so you can copy the views/timetable folder to views/custom/myagency and make any modifications needed. Any custom views folder should conatain pug templates called timetablepage.pug, timetablepage_full.pug, overview.pug, and overview_full.pug.

"templatePath": "views/custom/my-agency/"

useParentStation

{Boolean} Whether or not to use the parent_station of a stop, if specified instead of the platform or boarding area. Useful if different trips for the same route have different platforms that you want to show up in the timetable as separate stops. Defaults to true.

"useParentStation": true

verbose

{Boolean} If you don't want the import script to print any output to the console, you can set verbose to false. Defaults to true.

"verbose": false

zipOutput

{Boolean} Whether or not to zip the output into one zip file named timetables.zip. Defaults to false.

"zipOutput": false