Generating a documentation site helps you see and share details about your data models and sources in one easy place.
Generating documentation site in dbt
Start learning this pattern below
Jump into concepts and practice - no test required
dbt docs generate dbt docs serve
dbt docs generate creates the documentation files.
dbt docs serve starts a local web server to view the docs in your browser.
dbt docs generate
dbt docs serve
dbt docs generate && dbt docs serve
This example shows how to generate and then serve your dbt documentation site so you can open it in a browser and explore your data models and sources.
# Step 1: Generate the documentation files !dbt docs generate # Step 2: Serve the documentation site locally !dbt docs serve
Make sure your dbt project has descriptions in your schema.yml files to see useful info in the docs.
You can customize the docs site by adding markdown descriptions to models, columns, and sources.
The docs site updates every time you run dbt docs generate.
Generating docs creates a website showing your data models and sources.
Use dbt docs generate to build docs and dbt docs serve to view them.
This helps share and understand your data project easily.
Practice
dbt docs generate do in a dbt project?Solution
Step 1: Understand the purpose of
This command builds the documentation files for your dbt project, including models and sources.dbt docs generateStep 2: Differentiate from other commands
Unlikedbt runwhich runs transformations ordbt docs servewhich serves the docs,dbt docs generateonly creates the documentation files.Final Answer:
It creates a website with documentation for your data models and sources. -> Option DQuick Check:
dbt docs generatebuilds docs [OK]
- Confusing generate with run or serve commands
- Thinking it runs data transformations
- Assuming it deletes files
Solution
Step 1: Identify the command to serve docs
The commanddbt docs servestarts a local web server to view the generated documentation site.Step 2: Confirm other options are incorrect
dbt docs generateonly creates docs files, whiledbt docs viewanddbt docs startare not valid dbt commands.Final Answer:
dbt docs serve -> Option CQuick Check:
Serve command shows docs locally [OK]
- Using generate instead of serve to view docs
- Typing invalid commands like docs view or docs start
- Confusing generate and serve commands
dbt docs generate dbt docs serve
What will happen after running these commands?
Solution
Step 1: Understand the effect of
This command creates the documentation files needed for the docs site.dbt docs generateStep 2: Understand the effect of
This command starts a local server and opens the docs site in a browser using the generated files.dbt docs serveFinal Answer:
The documentation site is created and then opened in a local web browser. -> Option AQuick Check:
Generate then serve shows docs [OK]
- Thinking docs serve deletes docs
- Believing docs serve must run before generate
- Assuming docs generate runs data models
dbt docs serve but the documentation site does not open in your browser. What is the most likely cause?Solution
Step 1: Check prerequisites for serving docs
Thedbt docs servecommand needs the documentation files created bydbt docs generate.Step 2: Identify missing step
Ifdbt docs generatewas not run, the docs files don't exist, so the site won't open.Final Answer:
You forgot to rundbt docs generatefirst to create the docs files. -> Option BQuick Check:
Generate docs before serving [OK]
- Assuming docs serve works without generated files
- Thinking internet is required for docs serve
- Believing dbt run affects docs serving
dbt docs serve locally. Which approach is best?Solution
Step 1: Understand how docs are generated and shared
dbt docs generatecreates static documentation files that can be hosted anywhere.Step 2: Identify best way to share without local serving
Uploading generated docs to a web server allows team members to access the docs anytime without running commands locally.Final Answer:
Generate the docs withdbt docs generateand upload the generated files to a web server. -> Option AQuick Check:
Upload generated docs for team access [OK]
- Sharing local IP which may not be accessible
- Sending config files instead of docs
- Thinking dbt run publishes docs automatically
