4

I am trying to add the option on right click to "Add New Document" in Ubuntu 18.04 with GNOME desktop (VM). All of the documentation and online help tells me to create an empty .txt (or any other extention) file and place it in ~/Templates directory. That directory for some reason does not exist by defalut on my installation. No idea why. I tried adding it and then placing the empty file there but the right click menu doesn't change. Does anyone know why I didn't have this Templates directory by default and how I can successfully add the "Add New Document" option to my right click menu?? Thanks!

I used this commmand first: $ touch ~/Templates/Empty\ Document result: touch: cannot touch '/home/a7ger/Templates/Empty Document': No such file or directory I then did the following: $ mkdir ~/Templates $ touch ~/Templates/Empty\ Document This ran successfully as expected. But when I right click on dekstop or in a folder within Nautilus I still do not see the option to "Add New Document". Help!!

click link to see screenshot of right click menu after running commands.

2 Answers 2

7

I just found my new document missing, also the template didn't exist and the template directory wasnt set.

So, to the terminal as my user user:

mkdir -p ~/Templates && touch ~/Templates/Untitled\ Document;
xdg-user-dirs-update --set TEMPLATES ~/Templates;
nautilus -q && nautilus &

And the same as a one-liner:

mkdir -p ~/Templates && touch ~/Templates/Untitled\ Document && xdg-user-dirs-update --set TEMPLATES ~/Templates && nautilus -q && nautilus &

Note: restarting Nautilus is required so that the changes take effect for the current session, you could just reboot if you prefer.

I recently had to come back to this after a long while on ubuntu 20.04 I realised it had returned, but since I wrote this I have since found out a little tip I thought might be useful here.

When creating new files if you press F2 when clicking the new document option in the context menu, the rename prompt will open saving you from renaming the file after its been created.

2
  • 1
    Simple and efficient!
    – matteoh
    Sep 7, 2019 at 15:16
  • Tested and working in Ubuntu 18.04.3 LTS. Thanks a lot! Oct 24, 2019 at 19:41
4

There are several answers:

  • The Templates folder is specified in ~/.config/user-dirs.dirs file in XDG_TEMPLATES_DIR variable. Check for line XDG_TEMPLATES_DIR=... It should be XDG_TEMPLATES_DIR="$HOME/Templates" (or depends on your locale, check next point)
  • This folder is localized, so the exact name of the folder depends on your locale.
1
  • 1
    not working for me on ubuntu 18.10 somehow. i found out by looking inside this users-dirs.dirs , that my TEMPLATES settings pointed just to my $HOME dir only. NOT to the Template subdir. So i reset it using the cli tool ''xdg-user-dirs-update --set TEMPLATES ~/Templates'' and checked the content after. Now it was set correctly. However it still doesnt show "New Document" context menu, even though i have a file inside of Templates. Mar 24, 2019 at 13:07

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.