#sidebar items not ordered

8 messages · Page 1 of 1 (latest)

tall oasis
#

starlight; sidebar items not ordered alphabetically

keen lionBOT
#

Hi @tall oasis. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

By default, Starlight’s autogenerated sidebar groups are ordered alphabetically by file slug/filename. [Autogenerated groups; Sidebar sorting]

Key points to check:

  1. Autogenerated groups only
    Alphabetical sorting applies when you use autogenerate:

    starlight({
      sidebar: [
        {
          label: 'Constellations',
          autogenerate: { directory: 'constellations' },
        },
      ],
    });
    

    This will sort pages in that directory alphabetically by slug/filename. [Autogenerated groups]

  2. Manual items are not auto‑sorted
    If you define items yourself, Starlight keeps the order you specify:

    {
      label: 'Constellations',
      items: [
        'constellations/centaurus',
        'constellations/andromeda',
      ],
    }
    

    This will show Centaurus before Andromeda because that’s the order in the array. [Groups]

  3. Per‑page ordering in autogenerated groups
    Within autogenerated groups, you can override the default alphabetical order using frontmatter:

    ---
    title: My page
    sidebar:
      order: 1   # lower = higher in the list
    ---
    

    [Sidebar frontmatter]

If your items still appear “unsorted,” the most likely causes (based on the docs) are:

#
  • You’re using manual items and expecting automatic sorting.
  • You’re using sidebar.order in frontmatter, which intentionally overrides the alphabetical default in autogenerated groups.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@tall oasis Kapa.ai is still learning and improving, please let me know how I did by reacting below.

tall oasis
#

@keen lion Can I somehow specifiy to automatically sort it alphabetically?

keen lionBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

The knowledge sources only state that autogenerated groups are sorted alphabetically by default; they do not mention any option to auto‑sort manually defined items. [Autogenerated groups; Sidebar sorting]

So, based on the docs:

  • autogenerate: { directory: '...' } → items are automatically sorted alphabetically.
  • Manually listed items: [...] → order is exactly as you write them; there is no documented config to auto‑sort these alphabetically.

If you need automatic alphabetical sorting for a group, the documented way is to use an autogenerated group instead of a fully manual list.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: