"New Document" option is missing from contextual menu

Dear Gnome community,

Can you please help me fixing this annoying issue of not having anymore the “New Document” contextual (right-click) menu :question:

I’m running two Pop!_OS 21.04 distros, and both include the Files app with version 3.38.2-stable.
In one of them everything is fine, on the other which is my primary workstation I’m facing this problem.

Just to have a cleaner HOME dir, I wanted to change the location of the Templates folder. So, I followed the hints from this gnome wiki article, and deleted the ~/Templates folder.

Since, I that menu option disappeared, I created it back (mkdir ~/Templates) and populate it with some text files. But the problem remains, even after the reboot. I don’t know what else should I try.

The current state is:

$ cat ~/.config/user-dirs.dirs
# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 

XDG_TEMPLATES_DIR=$HOME/files/templates

$
$ xdg-user-dir TEMPLATES
/home/dxps/files/templates
$ 
$ ls /home/dxps/files/templates
 _ab_.txt  'New File.txt'
$ 

Any hints about it, please?

Thanks.

Create an empty file named “New Document” in your XDG_TEMPLATES_DIR (~/files/templates) and you’ll have the context menu item back. It’s a little weird to use a nonstandard location for this directory rather than the usual ~/Templates, but nothing stops you from doing so.

Thanks for the feedback, Michael, but as I mentioned I’m having some text files there.

The fact, that it works on one system and not on another makes me think that this is just some configuration issue. But the output of your current state seems to be right, which is weird. To be honest I am not sure what to try apart from running nautilus in gdb and set breakpoint on nautilus_get_templates_directory and see what is going on… which will be hard if you don’t have any experience with it.

1 Like

You said you created the text files in ~/Templates, but you changed $XDG_TEMPLATES_DIR to ~/files/templates for some reason, so that’s where they need to be placed…

1 Like

That link doesn’t point to the GNOME wiki! That’s the Arch Linux wiki, which is a distribution like Pop OS.

It looks like your config file is missing many lines. Try to copy the working file from the other computer change only the paths you wish, without erasing any lines.

@mcatanzaro Thanks, Michael. Just to remove any confusion, I simply wrote down all the facts.

So here is how the history unfolds:

  1. Removed ~/Templates folder.
  2. Created $HOME/files/templates folder and placed some text files in it (as listed above).
  3. Added XDG_TEMPLATES_DIR=$HOME/files/templates line into ~/.config/user-dirs.dirs.
    xdg-user-dir TEMPLATES command confirmed that this change is reflected.
  4. Since this issue (not having the ‘New Document’ contextual menu option) appeared, I recreated the initial state:
    • created ~/Templates folder and placed some text files into it as templates
    • plus removing (commenting out) the custom XDG_TEMPLATES_DIR setting
      in ~/.config/user-dirs.dirs file.

@antoniof Thanks for the feedback, António.

Yes, I’m aware that the wiki does not belong to Gnome, and it’s actually part of a different distro (which it happens that I played with in the past).
Not sure if that “emptiness” of that file is an issue. I’ll check out the other installation, but afaik I didn’t do any cleanup in it.

Thank you all for the feedback!

Indeed, the root cause was the fact that user-dirs.dirs file was kinda empty. I didn’t remove the lines manually, probably while trying xdg-user-dir or xdg-user-dirs-update made it empty.

Anyway, populating again with what I had on the other installment I finally got back New Document menu option. :slight_smile:

$ cat ~/.config/user-dirs.dirs

XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/files/templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/"
XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"

$
2 Likes

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