Skip to content

Support Chinese in html permalink href #13800

Closed

Description

@StageDog

Is your feature request related to a problem? Please describe.
html permalinks in Chinese docs are not permanent.
For example, given a <h2> titled as "调试方法", sphinx might generate a href="id3" for it; when I insert some <h2>s before it, "调试方法" goes to href="id6" or href="id{x}".
In a result, I'm always frustrated that I can't share my audience a permanent link that jumps to the exact section while keeping updating my docs.

docs generated by Sphinx fail to include Chinese into href ids

https://sillytavern-stage-girls-dog.readthedocs.io/工具经验/角色阶段/#id8

Image
docs generated by Vitepress work well

https://n0vi028.github.io/JS-Slash-Runner-Doc/guide/关于酒馆助手/介绍.html#酒馆助手-tavern-helper

Image

Describe the solution you'd like
Put Chinese in headings and figure captions into their href ids.

Describe alternatives you've considered
If this is not resolved, I may have to reluctantly migrate to other documentation tools.

Activity

  1. added
    type:proposal
    on Aug 2, 2025
  2. AA-Turner commented on Aug 2, 2025

    @AA-Turner
    Member

    Do you have a minimal reproducer? No member of the core team speaks Chinese, so we will need some help here.

    A

  3. added
    awaiting:response
    on Aug 2, 2025
  4. StageDog commented on Aug 2, 2025

    @StageDog
    Author

    Do you have a minimal reproducer? No member of the core team speaks Chinese, so we will need some help here.

    A

    sphinx-build . build on sample.zip

  5. AA-Turner commented on Aug 2, 2025

    @AA-Turner
    Member

    Plain text:

    .. index.rst 
    
    测试
    ==========
    
    ``href`` of the above heading is ``id1``.
    
    
    测试2
    ----------
    
    ``href`` of the above heading is ``id2``.
    
    
    测what试
    ----------
    
    ``href`` of the above heading is ``what``.
    # conf.py
    language = 'zh_CN'
  6. gmilde commented on Aug 7, 2025

    @gmilde
    Contributor

    This is a duplicate of #8709 (at least in the sense, that auto-generated IDs are used in the section "self-link" because of Docutils ID generation rules).

    The next version of Docutils should definitely try to solve this issue.

  7. ustccw commented on Aug 28, 2025

    @ustccw

    We encounter this issue frequently as well. Thank you @StageDog for bringing it to the official team and for successfully getting it resolved @gmilde .

  8. gmilde commented on Aug 29, 2025

    @gmilde
    Contributor

    The issue affects all non-latin alphabets (e.g. Cyrillic and Greek).

    слово 41
    --------
    ``href`` to the above heading is ``id1``.

    A workaround is to use an explicit target made of ASCII characters and starting with a letter. (The last explicit target becomes the section's ID)

    .. _λογος 42:
    .. _logos 42:
    
    λογος 42
    --------
    ``href`` to the above heading is ``logos-42``.

    The "ref" role requires an explicit refname:

    :ref:`слово 41` fails
    but :ref:`logos 42`, and :ref:`λογος 42` work.

    The rST reference syntax works also with the implicit target (but only in
    the same source document):

    `слово 41`_ and `λογος 42`_.
  9. jdillard commented on Aug 5, 2026

    @jdillard
    SponsorMember

    Thanks for the reproducer and discussion. As mentioned, this is the same underlying issue as #8709: headings that normalize to an empty identifier receive unstable sequential IDs such as id1. This affects Chinese and other non-Latin scripts.

    Let’s continue tracking the ID-generation work in #8709. Until then, an explicit target beginning with a letter can provide a stable permalink:

    .. _stable-target:
    
    测试
    ====

    Closing as a duplicate of #8709.

  10. locked as resolved and limited conversation to collaborators on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting:responsebuilder:htmltype:proposal

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions