JupyterLab URLs
JupyterLab Docs · نسخهٔ c233d4b14d54 · BSD-3-Clause
% Copyright (c) Jupyter Development Team.
% Distributed under the terms of the Modified BSD License.
(urls)=
# JupyterLab URLs
Like the classic notebook, JupyterLab provides a way for users to copy URLs that open a specific notebook or file. Additionally, JupyterLab URLs are an advanced part of the user interface that allows for managing workspaces. These two functions -- file paths and workspaces -- can be {ref}combined in URLs that open a specific file in a specific workspace <url-combine>.
(url-tree)=
File Navigation with /tree
JupyterLab's file navigation URLs adopts the nomenclature of the classic notebook; these URLs are /tree URLs:
http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynbBy default, the file browser will navigate to the folder containing the requested file. This behavior can be changed with the optional file-browser-path query parameter:
http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb?file-browser-path=/Entering the above URL will show the workspace root folder instead of the /path/to/ folder in the file browser.
The file can also be opened with a non-default viewer by using the optional open-with query parameter. The value can be a widget factory, file type, or file extension registered in JupyterLab. Common examples include txt for the text editor, json for the JSON viewer, and ipynb for the notebook viewer:
http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb?open-with=txtA space in a widget factory name can be written as + or %20:
http(s)://<server:port>/<lab-location>/lab/tree/path/to/README.md?open-with=Markdown+PreviewThe available viewers depend on the installed extensions and registered document factories. A widget factory name can differ from the item in the “Open With” submenu: the CSV viewer is listed as “CSV Viewer”, but its factory name is CSVTable. Opening a Markdown file with ipynb needs an extension that converts the file to a notebook, such as Jupytext. When the value matches no viewer, the file opens in its default viewer.
Linking Notebook Sections
To create an URL which will scroll to a specific heading in the notebook append a hash (#) followed by the heading text with spaces replaced by minus characters (-), for example:
/lab/tree/path/to/notebook.ipynb?#my-headingTo get a link for a specific heading, hover over it in a rendered markdown cell until you see a pilcrow mark (¶) which will contain the desired anchor link:
:alt: "A markdown cell with pilcrow mark (\xB6) which serves as an anchor link and\
: \ is placed after a heading"
:class: jp-screenshot:::{note} Currently disambiguation of headings with identical text is not supported. :::
JupyterLab experimentally supports scrolling to a specified cell by identifier using #cell-id=<cell-id> Fragment Identification Syntax.
/lab/tree/path/to/notebook.ipynb?#cell-id=my-cell-id:::{note} The cell-id fragment locator is not part of a formal Jupyter standard and subject to change. To leave feedback, please comment in the discussion: nbformat#317. :::
(url-workspaces)=
Managing Workspaces (URL)
JupyterLab sessions always reside in a workspace. Workspaces contain the state of JupyterLab: the files that are currently open, the layout of the application areas and tabs, etc. When the page is refreshed, the workspace is restored.
The default workspace does not have a name and resides at the primary /lab URL:
http(s)://<server:port>/<lab-location>/labAll other workspaces have a name that is part of the URL:
http(s)://<server:port>/<lab-location>/lab/workspaces/fooWorkspaces save their state on the server and can be shared between multiple users (or browsers) as long as they have access to the same server.
A workspace should only be open in a single browser tab at a time. If JupyterLab detects that a workspace is being opened multiple times simultaneously, it will prompt for a new workspace name.
(url-clone)=
Cloning Workspaces
You can copy the contents of a workspace into another workspace with the clone url parameter.
To copy the contents of the workspace foo into the workspace bar:
http(s)://<server:port>/<lab-location>/lab/workspaces/bar?clone=fooTo copy the contents of the default workspace into the workspace foo:
http(s)://<server:port>/<lab-location>/lab/workspaces/foo?cloneTo copy the contents of the workspace foo into the default workspace:
http(s)://<server:port>/<lab-location>/lab?clone=foo(url-reset)=
Resetting a Workspace
Use the reset url parameter to clear a workspace of its contents.
To reset the contents of the workspace foo:
http(s)://<server:port>/<lab-location>/lab/workspaces/foo?resetTo reset the contents of the default workspace:
http(s)://<server:port>/<lab-location>/lab/workspaces/lab?reset(url-combine)=
Combining URL Functions
These URL functions can be used separately, as above, or in combination.
To reset the workspace foo and load a specific notebook afterward:
http(s)://<server:port>/<lab-location>/lab/workspaces/foo/tree/path/to/notebook.ipynb?resetTo clone the contents of the workspace bar into the workspace foo and load a notebook afterward:
http(s)://<server:port>/<lab-location>/lab/workspaces/foo/tree/path/to/notebook.ipynb?clone=barTo reset the contents of the default workspace and load a notebook:
http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb?reset