move site suffix into title always
this tweaks the behavior of the title to always append ' - suffix' to any title (from the meta tag, or generated via request path), unless the page explicitly specifies an empty Title meta tag
This commit is contained in:
parent
dd7687884a
commit
f08c1117d8
@ -44,8 +44,9 @@ def display_page(path):
|
||||
|
||||
parent_navs = generate_parent_navs(resolved_path)
|
||||
|
||||
page_title = (get_meta_str(md, 'title') if md.Meta.get('title') else
|
||||
f'/{instance_resource_path_to_request_path(resolved_path)}')
|
||||
page_name = (get_meta_str(md, 'title') if md.Meta.get('title') else
|
||||
f'/{instance_resource_path_to_request_path(resolved_path)}')
|
||||
page_title = f'{page_name} - {app.config["TITLE_SUFFIX"]}' if page_name else app.config['TITLE_SUFFIX']
|
||||
logger.debug("title (potentially derived): %s", page_title)
|
||||
|
||||
return render('base.html', title=page_title, description=get_meta_str(md, 'description'),
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<title>{{ title }}{% if title %} - {% endif %}{{ config.TITLE_SUFFIX }}</title>
|
||||
<title>{{ title }}</title>
|
||||
{% if title %}<meta property="og:title" content="{{ title }}">{% endif %}
|
||||
{% if description %}<meta property="og:description" content="{{ description }}">{% endif %}
|
||||
{% if image %}<meta property="og:image" content="{{ image }}">{% endif %}
|
||||
|
@ -52,7 +52,7 @@ def test_page_with_card_metadata(client):
|
||||
"""Test that a page with opengraph metadata."""
|
||||
response = client.get('/more-metadata')
|
||||
assert response.status_code == 200
|
||||
assert b'<meta property="og:title" content="title for the page">' in response.data
|
||||
assert b'<meta property="og:title" content="title for the page - incorporeal.org">' in response.data
|
||||
assert b'<meta property="og:description" content="description of this page made even longer">' in response.data
|
||||
assert b'<meta property="og:image" content="http://buh.com/test.img">' in response.data
|
||||
|
||||
@ -61,11 +61,18 @@ def test_page_with_card_title_even_when_no_metadata(client):
|
||||
"""Test that a page without metadata still has a card with the derived title."""
|
||||
response = client.get('/no-title')
|
||||
assert response.status_code == 200
|
||||
assert b'<meta property="og:title" content="/no-title">' in response.data
|
||||
assert b'<meta property="og:title" content="/no-title - incorporeal.org">' in response.data
|
||||
assert b'<meta property="og:description"' not in response.data
|
||||
assert b'<meta property="og:image"' not in response.data
|
||||
|
||||
|
||||
def test_page_with_forced_empty_title_just_shows_suffix(client):
|
||||
"""Test that if a page specifies a blank Title meta tag explicitly, only the suffix is used in the title."""
|
||||
response = client.get('/forced-no-title')
|
||||
assert response.status_code == 200
|
||||
assert b'<title>incorporeal.org</title>' in response.data
|
||||
|
||||
|
||||
def test_page_has_modified_timestamp(client):
|
||||
"""Test that pages have modified timestamps in them."""
|
||||
response = client.get('/')
|
||||
|
3
tests/instance/pages/forced-no-title.md
Normal file
3
tests/instance/pages/forced-no-title.md
Normal file
@ -0,0 +1,3 @@
|
||||
Title:
|
||||
|
||||
some words are here
|
Loading…
Reference in New Issue
Block a user