Skip to content

Duplicate meta:viewport in base theme. #14751

Open

Description

@MTecknology

Describe the bug

I'm currently creating a custom theme for sphinx-doc and I'm trying to accomplish this by inheriting the base theme and updating a copy of layout.html until reaching parity.

Inside themes/base/layout.html:

  <head>
    <meta charset="{{ encoding }}" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    {{- metatags }}

On a nearly-empty sphinx-doc site, this left me with duplicate viewport tags in the final document.

It appears like viewport is being set somewhere else inside of sphinx-doc, and I suspect the "correct" fix is to simply remove the line from the template file.

How to Reproduce

conf.py:

#!/usr/bin/env python3
project = 'CV Heap'
author = 'Michael Lustfield'
copyright = '2026, CV Heap LLC. All rights reserved.'
exclude_patterns = ['README.rst']


# HTML Output
html_title = project
html_theme_path = ['_themes']
html_theme = 'casefile'

ls _themes/casefile/:

_css  layout.html  static  theme.toml

_themes/casefile/theme.toml:

[theme]
inherit = "basic"
stylesheets = [
    "site.css",
    "basic.css",
]

[options]
variable = "default value"
search_bar_text = "Search Documentation..."
#search_bar_text = "Search this site..."

Environment Information

Platform:              linux; (Linux-6.12.111+deb13-amd64-x86_64-with-glibc2.41)
Python version:        3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.21.2
Jinja2 version:        3.1.6
Pygments version:      2.18.0

Sphinx extensions

Additional context

No response

Activity

  1. zhengguangzhuo commented on Oct 19, 2026

    @zhengguangzhuo

    I reproduced this on current master: the basic theme emits two viewport meta tags, and the built-in bizstyle theme emits three because it adds another tag on top of the inherited layout. Docutils 0.21, the minimum supported version, already provides a viewport meta tag. I’m taking this and adding regression coverage for both themes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions