0
0
dbtdata~10 mins

Generating documentation site in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Generating documentation site
Run dbt docs generate
dbt parses project files
dbt builds documentation JSON
Documentation files created in target/ directory
Run dbt docs serve
Local web server starts
Open browser to view docs site
This flow shows how dbt generates and serves a documentation website from your project files.
Execution Sample
dbt
dbt docs generate
# Generates docs JSON files

dbt docs serve
# Starts local server to view docs
These commands generate the documentation files and then serve them locally for viewing.
Execution Table
StepActionProcessResult
1Run 'dbt docs generate'dbt reads models, sources, tests, and descriptionsCreates docs JSON files in target/ directory
2Files createdDocumentation JSON files readyFiles stored in target/catalog.json and target/index.html
3Run 'dbt docs serve'Starts local web server on default port 8080Server running, ready to serve docs
4Open browser at localhost:8080Browser requests docs siteDocumentation site loads showing project docs
5ExitStop serverDocs site no longer accessible locally
💡 Server stops when user interrupts; docs files remain for future use
Variable Tracker
VariableStartAfter Step 1After Step 3Final
docs_filesNoneCreated in target/Available for servingRemain on disk
server_statusStoppedStoppedRunningStopped after exit
Key Moments - 2 Insights
Why do we need to run 'dbt docs generate' before 'dbt docs serve'?
Because 'dbt docs generate' creates the documentation files needed by the server. Without these files, 'dbt docs serve' has nothing to show. See execution_table step 1 and 3.
What happens if you stop the server after running 'dbt docs serve'?
The documentation site will no longer be accessible locally, but the generated docs files remain on disk for future use. See execution_table step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is created after running 'dbt docs generate'?
ADocumentation JSON files in target/ directory
BLocal web server
CBrowser window
DDatabase tables
💡 Hint
Check execution_table row 1 under Result column
At which step does the local web server start running?
AStep 1
BStep 3
CStep 4
DStep 5
💡 Hint
Look at execution_table Step 3 under Process and Result
If you skip 'dbt docs generate' and run only 'dbt docs serve', what will happen?
Adbt will generate docs automatically
BDocs site will load normally
CError because docs files are missing
DServer will start but no docs will show
💡 Hint
Refer to key_moments about the need to generate docs before serving
Concept Snapshot
dbt docs generate: Creates documentation JSON files from your project.
dbt docs serve: Starts a local web server to view the docs site.
Docs files are stored in target/ directory.
Always generate docs before serving.
Stop server to end local docs access.
Full Transcript
To generate a documentation site in dbt, first run 'dbt docs generate'. This command reads your project files like models and sources, then creates JSON documentation files in the target/ directory. Next, run 'dbt docs serve' to start a local web server, usually on port 8080. Open your browser to localhost:8080 to view the documentation site. The server runs until you stop it. The docs files remain on disk for future use. Remember, you must generate docs before serving, or the site will not load.