105

I would like to to have a "create new document" option in the right-click menu.

Currently it looks like this :

enter image description here

I am using Ubuntu GNOME 16.04 LTS with GNOME 3.20.

muru
  • 207,228
Severus Tux
  • 10,126

8 Answers8

152
  1. See if you have ~/Templates folder2. Create one if it is missing using command:

    mkdir ~/Templates
    
  2. Now create an empty file from command prompt:1

    touch ~/Templates/Text\ File.txt
    

The "Create Document" option is back again and you can create a new text file or a new document.

1 The backslash is used to tell the shell that the space following it is part of the filename. Since the shell recognizes spaces as delimiters between commands/options/arguments, unless you "quote it", 'quote it', or quote\ it, the shell will treat whatever comes after the space as a separate argument.

2 The ~/Templates folder is localized, change his name accordingly to your localization (ex: ~/Modèles for French localization).

HMagdy
  • 1,639
24

You can go into your ~/Templates folder and create templates yourself, then they will appear in the right-click menu. For example:

cd Templates

touch Filename.txt
Naveen
  • 341
14

This functionality has been removed from Nautilus 3.20 (either by error or on purpose). There is a bug report on it here. If it turns out to be a bug it will be fixed upstream and then will either be back in 3.22 or backported into 3.20, or if this has been done on purpose then as you can see from the LP bug report they are wanting to make it a distro specific patch.

9

It seems like when the templates folder is empty this option is disabled. The simplest fix for this problem is to create a file in the templates folder:

touch `xdg-user-dir TEMPLATES`/Empty\ Text\ File.txt

It's definitely a bug as stated.

pr.nizar
  • 790
8

In the case you are using an ubuntu with a different language that english, first check where your Templates folder is.

vi ~/.config/user-dirs.dirs

And in this file, check for XDG_TEMPLATES_DIR=. In spanish for example you will have something like:

XDG_DESKTOP_DIR="$HOME/Escritorio"
XDG_DOWNLOAD_DIR="$HOME/Descargas"
XDG_TEMPLATES_DIR="$HOME/Plantillas"
XDG_PUBLICSHARE_DIR="$HOME/Público"
XDG_DOCUMENTS_DIR="$HOME/Documentos"
XDG_MUSIC_DIR="$HOME/Música"
XDG_PICTURES_DIR="$HOME/Imágenes"
XDG_VIDEOS_DIR="$HOME/Vídeos"

Then you can apply the solution listed in the other answers:

mkdir ~/Plantillas  (or the name listed before)
touch ~/Plantillas/Documento\ de\ Texto.txt

And that is all.

3

this method didn't quite work for me, items in the Templates folder weren't showing up in the context menu. something needed to be restored about how the system identifies and uses the Templates folder.

to fix this, i installed ubuntu tweak like so:

wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu xenial-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'
sudo apt-get update
sudo apt-get install ubuntu-tweak

and then used this method, namely, delete your Templates folder and then use this method to 'restore' the Templates folder, worked for me in 17.04 on a thinkpad t530:

How can I restore template functionality after having deleted the Templates folder in 12.10?

muru
  • 207,228
2

You can also use the LibreOffice 'Save As' feature to save an empty Document, Spreadsheet, Presentation or Drawing in the same way. Using touch to create files won't work (didn't for me anyway) since ubuntu still recognises them as text files. So you can have any type of new file available if you set up the right template for it, not just text files.

mrchuck
  • 41
0

Below are steps that worked for me on Ubuntu 18 and Nautilus aka Files. For more background info see ArchWiki.

  • Create a directory for template files and some template:
$ mkdir ~/Sausage && touch $_/textfile.txt
  • Check what the templates directory is currently set to (in my case it was set to my user's home directory):
$ xdg-user-dir TEMPLATES
/home/<username>/
  • Set it to the desired directory:
$ xdg-user-dirs-update --set TEMPLATES ~/Sausage
  • You can check this worked by either re-running the previous command or viewing the config file that holds these settings (it's where the 'TEMPLATES' part comes from):
$ less ~/.config/user-dirs.dirs
  • Close Nautilus to make it pick up the changes:
$ pkill nautilus
  • Should be able to create a new document now:
$ nautilus &

Here is how the new folder appeared before updating the configuration:

before updating the configuration

and after the restart:

and after

and the context menu in action:

context menu in action