File tree Expand file tree Collapse file tree 3 files changed +44
-6
lines changed
tests/integration/multi_page Expand file tree Collapse file tree 3 files changed +44
-6
lines changed Original file line number Diff line number Diff line change @@ -235,13 +235,14 @@ def register_page(
235
235
order `0`
236
236
237
237
- `title`:
238
- (string or function) The name of the page <title>. That is, what appears in the browser title.
239
- If not supplied, will use the supplied `name` or will be inferred by module,
240
- e.g. `pages.weekly_analytics` to `Weekly analytics`
238
+ (string or function) Specifies the page title displayed in the browser tab.
239
+ If not supplied, the app's title is used if different from the default "Dash".
240
+ Otherwise, the title is the supplied `name` or inferred from the module name.
241
+ For example, `pages.weekly_analytics` is inferred as "Weekly Analytics".
241
242
242
243
- `description`:
243
244
(string or function) The <meta type="description"></meta>.
244
- If not supplied, then nothing is supplied .
245
+ If not supplied, the app's description is used else None .
245
246
246
247
- `image`:
247
248
The meta description image used by social media platforms.
@@ -319,10 +320,18 @@ def register_page(
319
320
)
320
321
page .update (
321
322
supplied_title = title ,
322
- title = (title if title is not None else page ["name" ]),
323
+ title = title
324
+ if title is not None
325
+ else CONFIG .title
326
+ if CONFIG .title != "Dash"
327
+ else page ["name" ],
323
328
)
324
329
page .update (
325
- description = description if description else "" ,
330
+ description = description
331
+ if description
332
+ else CONFIG .description
333
+ if CONFIG .description
334
+ else "" ,
326
335
order = order ,
327
336
supplied_order = order ,
328
337
supplied_layout = layout ,
Original file line number Diff line number Diff line change @@ -366,6 +366,9 @@ class Dash:
366
366
functions. The syntax for this parameter is a dict of State objects:
367
367
`routing_callback_inputs={"language": Input("language", "value")}`
368
368
NOTE: the keys "pathname_" and "search_" are reserved for internal use.
369
+
370
+ :param description: Sets a default description for meta tags on Dash pages (use_pages=True).
371
+
369
372
"""
370
373
371
374
_plotlyjs_url : str
@@ -404,6 +407,7 @@ def __init__( # pylint: disable=too-many-statements
404
407
add_log_handler = True ,
405
408
hooks : Union [RendererHooks , None ] = None ,
406
409
routing_callback_inputs : Optional [Dict [str , Union [Input , State ]]] = None ,
410
+ description = None ,
407
411
** obsolete ,
408
412
):
409
413
_validate .check_obsolete (obsolete )
@@ -458,6 +462,7 @@ def __init__( # pylint: disable=too-many-statements
458
462
title = title ,
459
463
update_title = update_title ,
460
464
include_pages_meta = include_pages_meta ,
465
+ description = description ,
461
466
)
462
467
self .config .set_read_only (
463
468
[
Original file line number Diff line number Diff line change @@ -235,3 +235,27 @@ def test_pala005_routing_inputs(dash_duo, clear_pages_state):
235
235
# Changing the language Input re-runs the layout function
236
236
dash_duo .select_dcc_dropdown ("#language" , "fr" )
237
237
dash_duo .wait_for_text_to_equal ("#contents" , "Le hash dit: #123" )
238
+
239
+
240
+ def get_app_title_description ():
241
+ app = Dash (
242
+ __name__ , use_pages = True , title = "App Title" , description = "App Description"
243
+ )
244
+ dash .register_page ("home" , layout = html .Div ("Home" ), path = "/" )
245
+ dash .register_page (
246
+ "page1" ,
247
+ layout = html .Div ("Page1" ),
248
+ title = "Page 1 Title" ,
249
+ description = "Page 1 Description" ,
250
+ )
251
+ app .layout = html .Div (dash .page_container )
252
+ return app
253
+
254
+
255
+ def test_pala006_app_title_discription (dash_duo , clear_pages_state ):
256
+ dash_duo .start_server (get_app_title_description ())
257
+
258
+ assert dash .page_registry ["home" ]["title" ] == "App Title"
259
+ assert dash .page_registry ["page1" ]["title" ] == "Page 1 Title"
260
+ assert dash .page_registry ["home" ]["description" ] == "App Description"
261
+ assert dash .page_registry ["page1" ]["description" ] == "Page 1 Description"
You can’t perform that action at this time.
0 commit comments