Organise Config Files Using XDG Directories#
Prerequisites#
NeoMutt installed and working with a basic configuration.
Familiarity with where your current config, cache, and mail files live.
The XDG Base Directory Layout#
The XDG Base Directory Specification defines standard locations for configuration, data, and cache files. Using these keeps your home directory clean and makes backup easier.
Purpose |
XDG Variable |
Default |
NeoMutt usage |
|---|---|---|---|
Configuration |
|
|
|
Data (mail) |
|
|
|
Cache |
|
|
|
Move Configuration to XDG_CONFIG_HOME#
Create the config directory:
mkdir -p ~/.config/neomutt
Move your config file:
mv ~/.neomuttrc ~/.config/neomutt/neomuttrc
Move any sourced files (aliases, account configs) into the same directory.
Start NeoMutt and confirm it finds the config.
Expected result: NeoMutt reads ~/.config/neomutt/neomuttrc automatically β it is higher priority than ~/.neomuttrc in the search order.
Move Cache to XDG_CACHE_HOME#
Create the cache directory:
mkdir -p ~/.cache/neomutt
Update your config:
set header_cache = "~/.cache/neomutt/headers"
set message_cachedir = "~/.cache/neomutt/bodies"
Expected result: cache files are stored outside your config directory and can be safely excluded from backups.
Store Mail in XDG_DATA_HOME#
Create the mail directory:
mkdir -p ~/.local/share/mail
Update your config:
set folder = "~/.local/share/mail/you@example.com"
If you use mbsync, update
~/.mbsyncrcto match:
MaildirStore you@example.com-local
Path ~/.local/share/mail/you@example.com/
Inbox ~/.local/share/mail/you@example.com/INBOX
If you use Notmuch, update
~/.notmuch-config:
[database]
path=/home/you/.local/share/mail
Expected result: mail data lives in ~/.local/share/mail/, separate from config and cache.
Store msmtp Config in XDG_CONFIG_HOME#
Create the directory:
mkdir -p ~/.config/msmtp
Place your msmtp config at
~/.config/msmtp/config. msmtp checks this path by default on most systems.
Expected result: SMTP configuration follows the same layout as NeoMuttβs.
Organise Per-Account Config Files#
For multi-account setups, keep per-account configs in subdirectories:
~/.config/neomutt/
βββ neomuttrc
βββ accounts/
βββ personal.muttrc
βββ work.muttrc
Source them from your main config:
source ~/.config/neomutt/accounts/personal.muttrc
source ~/.config/neomutt/accounts/work.muttrc
Expected result: account-specific settings are isolated in their own files.
Example: Complete XDG Directory Tree#
~/.config/
βββ neomutt/
β βββ neomuttrc
β βββ accounts/
β β βββ you@example.com.muttrc
β βββ aliases
β βββ mailcap
βββ msmtp/
β βββ config
~/.cache/
βββ neomutt/
βββ headers/
βββ bodies/
~/.local/share/
βββ mail/
βββ you@example.com/
βββ INBOX/
βββ Sent/
βββ Drafts/
What to Back Up#
Directory |
Back up? |
Notes |
|---|---|---|
|
Yes |
All configuration |
|
Yes |
SMTP configuration |
|
Yes |
Sync configuration |
|
Yes |
Search configuration |
|
No |
Regenerated automatically |
|
Optional |
Can be re-synced from server |
See Back Up Your Configuration for more on backups and Writing Your First Configuration for config file search order.