Skip to content

Commit 056ba91

Browse files
authored
chore(docs): add more redirects + catchall (#6442)
1 parent 02300de commit 056ba91

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

docs/_scripts/notebook_hooks.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,25 @@
129129
"how-tos/human_in_the_loop/edit-graph-state.ipynb": "https://docs.langchain.com/oss/python/langgraph/use-time-travel",
130130

131131
# LGP mintlify migration redirects
132+
"examples/index.md": "https://docs.langchain.com/oss/python/learn",
133+
"guides/index.md": "https://docs.langchain.com/oss/python/langgraph/overview",
134+
"concepts/index.md": "https://docs.langchain.com/oss/python/langgraph/overview",
135+
"tutorials/index.md": "https://docs.langchain.com/oss/python/learn",
136+
"llms-txt-overview.md": "https://docs.langchain.com/llms.txt",
137+
"tutorials/rag/langgraph_adaptive_rag.md": "https://docs.langchain.com/oss/python/langgraph/agentic-rag",
138+
"tutorials/multi_agent/multi-agent-collaboration.ipynb": "https://docs.langchain.com/oss/python/langchain/multi-agent",
139+
"how-tos/create-react-agent-manage-message-history.ipynb": "https://docs.langchain.com/oss/python/langgraph/add-memory",
140+
"how-tos/many-tools.ipynb": "https://docs.langchain.com/oss/python/langchain/tools",
141+
"tutorials/customer-support/customer-support.ipynb": "https://docs.langchain.com/oss/python/langgraph/agentic-rag",
142+
"how-tos/react-agent-structured-output.ipynb": "https://docs.langchain.com/oss/python/langchain/agents#structured-output",
143+
"tutorials/code_assistant/langgraph_code_assistant.ipynb": "https://docs.langchain.com/oss/python/langgraph/agentic-rag",
144+
"tutorials/multi_agent/hierarchical_agent_teams.ipynb": "https://docs.langchain.com/oss/python/langchain/supervisor",
132145
"tutorials/auth/getting_started.md": "https://docs.langchain.com/langsmith/auth",
133146
"tutorials/auth/resource_auth.md": "https://docs.langchain.com/langsmith/resource-auth",
134147
"tutorials/auth/add_auth_server.md": "https://docs.langchain.com/langsmith/add-auth-server",
135148
"how-tos/use-remote-graph.md": "https://docs.langchain.com/langsmith/use-remote-graph",
136149
"how-tos/autogen-integration.md": "https://docs.langchain.com/langsmith/autogen-integration",
150+
"how-tos/human_in_the_loop/wait-user-input.ipynb": "https://docs.langchain.com/oss/python/langgraph/interrupts",
137151
"cloud/how-tos/use_stream_react.md": "https://docs.langchain.com/langsmith/use-stream-react",
138152
"cloud/how-tos/generative_ui_react.md": "https://docs.langchain.com/langsmith/generative-ui-react",
139153
"concepts/langgraph_platform.md": "https://docs.langchain.com/langsmith/deployments",
@@ -219,12 +233,15 @@
219233
"tutorials/get-started/6-time-travel.md": "https://docs.langchain.com/oss/python/langgraph/quickstart",
220234
"tutorials/langsmith/local-server.md": "https://docs.langchain.com/oss/python/langgraph/local-server",
221235
"tutorials/workflows.md": "https://docs.langchain.com/oss/python/langgraph/workflows-agents",
236+
"tutorials/plan-and-execute/plan-and-execute.ipynb": "https://docs.langchain.com/oss/python/langchain/middleware/built-in#to-do-list",
237+
"tutorials/langgraph-platform/local-server/local-server.md": "https://docs.langchain.com/langsmith/local-server",
222238
"concepts/agentic_concepts.md": "https://docs.langchain.com/oss/python/langgraph/workflows-agents",
223239
"guides/index.md": "https://docs.langchain.com/oss/python/langchain/overview",
224240
"agents/overview.md": "https://docs.langchain.com/oss/python/langchain/agents",
225241
"agents/run_agents.md": "https://docs.langchain.com/oss/python/langgraph/quickstart",
226242
"concepts/low_level.md": "https://docs.langchain.com/oss/python/langgraph/graph-api",
227243
"how-tos/graph-api.md": "https://docs.langchain.com/oss/python/langgraph/graph-api",
244+
"how-tos/react-agent-from-scratch.ipynb": "https://docs.langchain.com/oss/python/langchain/quickstart",
228245
"concepts/functional_api.md": "https://docs.langchain.com/oss/python/langgraph/functional-api",
229246
"how-tos/use-functional-api.md": "https://docs.langchain.com/oss/python/langgraph/functional-api",
230247
"concepts/pregel.md": "https://docs.langchain.com/oss/python/langgraph/pregel",
@@ -793,6 +810,17 @@ def on_post_build(config):
793810
# Track which paths have explicit redirects
794811
redirected_paths = set()
795812

813+
# Collect all existing HTML files in the site
814+
all_html_files = set()
815+
for root, dirs, files in os.walk(site_dir):
816+
for file in files:
817+
if file.endswith(".html"):
818+
# Get relative path from site_dir
819+
html_path = os.path.relpath(os.path.join(root, file), site_dir)
820+
# Normalize path separators to forward slashes
821+
html_path = html_path.replace(os.sep, "/")
822+
all_html_files.add(html_path)
823+
796824
# Process explicit redirects from REDIRECT_MAP
797825
for page_old, page_new in REDIRECT_MAP.items():
798826
# Convert .ipynb to .md for path calculation
@@ -847,6 +875,24 @@ def on_post_build(config):
847875

848876
_write_html(site_dir, old_html_path, new_html_path)
849877

878+
# Create catch-all redirects for any HTML files not explicitly redirected
879+
catchall_url = "https://docs.langchain.com/oss/python/langgraph/overview"
880+
for html_file in all_html_files:
881+
# Skip if this file is already explicitly redirected
882+
if html_file in redirected_paths:
883+
continue
884+
885+
# Skip the root index.html (we handle that separately)
886+
if html_file == "index.html":
887+
continue
888+
889+
# Skip reference documentation (keep those accessible)
890+
if html_file.startswith("reference/"):
891+
continue
892+
893+
# Create redirect for this unmapped file
894+
_write_html(site_dir, html_file, catchall_url)
895+
850896
# Create root index.html redirect
851897
root_redirect_html = """<!doctype html>
852898
<html lang="en">

0 commit comments

Comments
 (0)