Tag ordering in the tag index built in Obsidian Publish

When publishing through Obsidian Publish, all tags in the body of Markdown files become links to indexes of all files with the same tag. However, the order of the files in the tag index, while staying the same, seems random: it is at least not alphabetical. My guess is that the order is by descending modification date, which can be inconvenient for my purposes.

Is there a possibility to influence this ordering?

I asked ChatGPT.

You’re correct that in Obsidian Publish, the default order for tag indexes is not alphabetical, and it tends to follow the descending modification date, or a similar logic related to the publishing system’s internal ordering. However, Obsidian Publish doesn’t currently provide a native way to adjust the ordering of files in tag indexes.

Here are a few potential workarounds you could consider:

1. Manual Indexing with Markdown

You could create a custom “index” page for each tag where you manually list the files in the order you want. This way, instead of relying on Obsidian Publish to generate the tag index, you could control the ordering. You could even link to the specific files or sections within those files as needed.

For example, for a tag like #project, you could create a page called projects.md with something like:

# Projects

- [Project A](project-a.md)
- [Project B](project-b.md)
- [Project C](project-c.md)

This approach requires some manual maintenance, but it gives you full control over the order and content.

2. Customizing the Tag System with a Plugin

Obsidian supports third-party plugins, and there might be a plugin that lets you control tag indexing or ordering. A plugin like “Dataview” could help generate custom views that allow sorting and filtering, including custom ordering of files with tags.

For instance, you can create a Dataview query like this:

```dataview
table file.name as "Project", file.mtime as "Last Modified"
from "folder"
where contains(file.tags, "#project")
sort file.name asc

This will list all the files tagged with #project and sort them alphabetically. You can then include this query inside any page, or even create a dedicated tag index that’s fully customizable.

3. Feature Request to Obsidian

If the above solutions aren’t ideal, it could be worth suggesting this feature directly to the Obsidian team or in the community forum. Many features are regularly added based on user feedback, and you might get a more flexible tag ordering option in future updates.

4. Using Metadata in Front Matter

If you’re using front matter in your notes (YAML blocks at the top of the file), you can specify metadata like “priority” or “date” to manually influence the order when generating custom tag indexes or in your queries.

For example:

---
tags: [project]
priority: 1
---

You could then sort files based on the priority value when using Dataview or similar plugins, giving you more control over the organization.

5. CSS Tweaks (for Visual Appearance)

If you just want to change the visual order and not the underlying structure, you could potentially use CSS overrides to control the appearance of the tag index pages. This approach is more limited but could work for specific use cases where you want to reorder the tags on the front end without changing the actual file order.

I ended up doing something close to Solution 2.

Using Templater I built separate files for each tag, and set a custom sorting that was suitable for me. In the start of published files, I write the links to the tag files automatically through publish.js.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.