dbt docs generate

Galaxy Glossary

What does the dbt docs generate command do and how do I use it?

dbt docs generate builds a static website with lineage graphs, model metadata, and tests based on your compiled dbt project.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

What Is dbt docs generate?

dbt docs generate is a CLI command that compiles your project metadata into a searchable static site, letting teams explore lineage, columns, and tests without opening code.

Why Use dbt docs generate in Analytics Engineering?

Accurate, always-up-to-date documentation reduces onboarding time, surfaces broken contracts early, and satisfies data governance requirements.

How Does dbt docs generate Work Under the Hood?

The command parses your manifest.json, catalog.json, and run results, then writes HTML, JS, and JSON assets to a target directory.

Which Files Does dbt docs generate Read?

It uses manifest.json for DAG and metadata, catalog.json for column stats, and run_results.json for test outcomes.

How Do I Run dbt docs generate?

Navigate to your project root and run the command in the same environment used for dbt run.

Basic Command

dbt docs generate

This builds docs in target by default.

Specifying Target and Output Directory

dbt docs generate --profiles-dir ~/.dbt --target prod --output-dir ./public_docs

Override where metadata is read and where HTML is written.

How Do I Serve and Share Generated Docs?

Use dbt docs serve for a localhost preview, then upload contents of the output directory to S3, GCS, GitHub Pages, or Vercel.

Example: Generating Docs for a Snowflake Project

# activate venv and set creds
source venv/bin/activate
export SNOWFLAKE_ROLE=TRANSFORMER
dbt run --target prod
dbt docs generate --target prod

Open target/index.html to explore lineage and tests.

Best Practices for dbt docs generate

Schedule docs generation after each production run, version docs per git tag, and enforce column descriptions via CI tests.

Common Pitfalls and How to Fix Them

Missing catalog.json often means dbt run was skipped; rerun models or pass --full-refresh to rebuild stats.

How Does Galaxy Enhance dbt docs Workflows?

Galaxy links directly from query results to the corresponding model in your generated docs, letting engineers jump from SQL to lineage in one click.

Key Takeaways

dbt docs generate produces shareable, self-service documentation that boosts team velocity and trust in data models.

Why dbt docs generate is important

Up-to-date documentation prevents knowledge silos. By automatically generating a browsable site, teams reduce onboarding time, debug lineage breaks faster, and satisfy governance audits. Automated docs also free engineers from manual wiki edits, ensuring accuracy aligns with the codebase.

dbt docs generate Example Usage


dbt docs generate --target production --output-dir ./site

dbt docs generate Syntax



Common Mistakes

Frequently Asked Questions (FAQs)

How do I view docs locally?

Run dbt docs serve and open the provided URL, usually http://localhost:8080.

Can I automate docs deployment?

Yes. In CI/CD, run dbt rundbt docs generate ➔ sync target to S3 or push to GitHub Pages.

Why is my lineage graph empty?

This happens when the manifest is missing nodes. Ensure model and source files were parsed successfully and no syntax errors exist.

Can I open dbt documentation inside Galaxy?

Galaxy can embed the generated site in a side panel, letting you click from a query to its model docs without leaving the SQL editor.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.