147

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
  • 69,302
Nathan Dyer
  • 2,127

1 Answers1

214

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
  • 174,664
  • 29
    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
  • 1
    @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
  • @jdpipe these "templates" are not meant in a OpenDocument sense, but a more generic way. they might even be just txt files, desktop files, scripts etc. ...they are more or less files which get copied. || none the less you can simply save an empty file generated of your OpenDocument template in the template folder and you're good to go. - pro tip: you might want remove the metadata from your file(s) in the template folder. – DJCrashdummy Jun 19 '24 at 12:06
  • IMHO easier than manually editing the file via gedit ~/.config/user-dirs.dirs and perhaps also a little bit more foolproof would be something like xdg-user-dirs-update --set TEMPLATES "$HOME/my templates". – DJCrashdummy Jun 19 '24 at 12:08