138

For as long as I can remember, every time I install Ubuntu there is a folder in the home directory called "Templates." I've always just deleted it, but I'm curious: what's it supposed to be used for, and why is it in the default install?

Braiam
  • 66,947
  • 30
  • 177
  • 264
Nathan Dyer
  • 2,037
  • 3
  • 16
  • 15
  • 4
    Great question. I've always done the same thing, deleting the folder after installing. I think @fossfreedom just made our lives a little bit easier. – Tom Brossman Jan 12 '12 at 17:20

1 Answers1

198

If you drop any files in this folder, for example

enter image description here

then when you right-click and create a new document, you can select any of these files as a basis for the new file - i.e. a template.

enter image description here

For as long as I remember, this has always been a standard feature on many desktops such as Gnome.


If you have deleted the folder and need to restore this functionality:

gedit ~/.config/user-dirs.dirs

Check that there is a line containing the following - if not, add this line.

XDG_TEMPLATES_DIR="$HOME/Templates"
fossfreedom
  • 171,546
  • 47
  • 376
  • 404
  • 27
    You just answered hours of questions. – BenjaminRH Apr 18 '12 at 17:00
  • So does this play well with OpenDocument templates, eg .ott files and the like? – jdpipe Jun 07 '16 at 12:52
  • Does freedesktop specify the list of "well known" directories and what they should do somewhere, or is the `xdg-user-dir` implementation all we get? https://www.freedesktop.org/wiki/Software/xdg-user-dirs/ – Ciro Santilli OurBigBook.com Dec 10 '16 at 12:11
  • Thanks, This works great on `ext4` mounts but on filesystem types `fuse` or `cifs` mounts *(i.e. network drives and local ntfs drives)* the **executable flag** gets set automatically upon creation of the file. How can I inhibit this? – Pau Coma Ramirez Jan 28 '21 at 10:06
  • @Mark, your link doesn't work. I point here to your other answer https://askubuntu.com/a/652664/15943 – alfC Jul 22 '21 at 03:10
  • @jdpipe, probably it doens't play well with ott template files. It will create another template rather than a real document. – alfC Jul 22 '21 at 03:14
  • If you want to be able to create "folder templates" (in addition to single-file templates), take a look at the Nautilus extension available at https://gitlab.com/edgimar/nautilus-new-folder-from-template – Mark Jul 30 '21 at 16:28
  • Note that this Templates folder isn't recognised by KDE; on Kubuntu, add a .desktop file in /usr/share/templates/ with the corresponding example file in /usr/share/templates/.source/ (guide here: https://dev.to/ksckaan1/creating-a-template-on-kde-plasma-3a9o ) – Saeed Baig Jan 09 '23 at 09:16