How do I assign a template to a document?

I know that Libreoffice has a template directory and that it differentiates between template documents and working documents.

I also see there is a menu option Files > Templates > Assign Template to current document

However, the menu item has no effect. It prompts me to select the template document, but the template is not applied.

So, how do I assign a template to my document?

Thanks

1 Like

Are the paragraph and character styles of your document named the same as the ones of the template?

Please do not write a question as an answer. Use the comment function for this. Thanks.

From the LibreOffice Writer 5.4 Guide, Chapter 10, Working with Templates, pp. 227–228:

Associating a document with a different template

At times you might want to associate a document with a different template, or perhaps you’re working with a document that did not start from a template.

One of the major advantages of using templates is the ease of updating styles in more than one document, as described in Chapter 9, Working with Styles. If you update styles in a document by loading a new set of styles from a different template (as described in Chapter 9), the document has no association with the template from which the styles were loaded—so you cannot use this method. What you need to do is associate the document with the different template.

For best results, the names of styles should be the same in the existing document and the new template. If they are not, you will need to use Edit > Find & Replace to replace old styles with new ones. See Chapter 2, Working with Text: Basics, for more about replacing styles.

  1. Use File > New > Templates. In the Templates dialog, double-click the template you want to use. A new document opens, containing any text or graphics that were in the template.

  2. Delete any unwanted text or graphics from this new document.

  3. Open the document you want to change. (It opens in a new window.)

  4. Use Edit > Select All, or press Ctrl+A, to select everything in the document.

  5. Click in the blank document created in step 1. Use Edit > Paste, or press Ctrl+V, to paste the contents from the old document into the new one.

  6. Update the table of contents, if there is one. Close the old file without saving. Use File > Save As to save this new file with the name of the file from which content was taken. When asked, confirm you wish to overwrite the old file. Or, you may prefer to save the new file under a new name and preserve the old file under its original name.

Caution

Any changes recorded (tracked) in the document will be lost during this process. The resulting document will contain only the changed text.

This is one area where I think OpenOffice Writer outshines LibreOffice. It is much easier to assign a template in OO via the menu item of that name. I would suggest assigning the template in OO and then editing in LO if you must.

The procedure given above is akin to create a brand new document with loss of some information (such as history). When in need, I use a workaround which is not for the faint of heart.

I save my doc as .fodt (flat XML) and I edit manually the code to alter the reference to the template (caution, the template location is some path relative to the current document). For unknown reason, I sometimes need to alter the template date for the change to be noticed by LO.

@ajlittoz Could you give a few more details about the “elements” (in the XML sense) you actually edit for “template” and “template date”?
I just created a new .odt file, saved it as .fodt, opened this in a text editor, and searched on “template”. The only thing it found was “<config:config-item config:name=“UpdateFromTemplate” config:type=“boolean”>true</config:config-item>”. NB my LO version is 5.1.6.2.

@mrodent: sorry, I just noticed your question today (the notification feature has been quite buggy for some time now and does not work satisfactorily on comments).

The XML element is <meta:template … />. However I don’t recommend you start patching the .fodt. Try first to work with extension DocumentTemplateChanger. This is much more reliable and less error-prone. Go for a manual patch only if you don’t succeed with the extension.

@ajlittoz: please provide an answer with the extension!

Have a look at:

Tutorial exercise: Styles in Writer - LibreOffice 6.4

Style in Writer - V6

Assign style:

Mark each text. Double-click on the Style ″Style name″.

If you have provided a document with your desired style, you should then save it as a document template.

I hope it helps you. I wish you success.

With me Windows 10 Home; Version 1909; 64-Bit | LibreOffice, Version: 6.4.0.3 (x64).

Changing or assigning a template is very easy with DocumentTemplateChanger extension.

(link edited on 2020-10-16 after a URL changer on the extensions site)

Load and install the extension from the link above. This will patch menu File>Templates adding two new items Change template (current document) and Change template (folder). The second one is for bulk change of all documents in a folder.

When you select a command, the pop-up offers the choice among four actions (some of them may be grayed out if they do not make sense in the current context):

  • connect to a template: associate a template to an orphan document or change the current template

    You can select a template anywhere in the computer, not only in the “standard” template folder (see Tools>Options\, LibreOffice>Paths`)

  • cut link to template: orphan the document

    The document is no longer associated with the template. Changes to the template will no longer affect the document.

  • deactivate link to the template

  • reactivate link to the template

    I have not tested these commands. From the help, they seem to behave like the update dialog when opening a document with a change template, i.e. you can temporarily suspend styles updates or reallow them.

The help warns against the fact that some changes are not effective immediately. It is thus better to close the document and reopen it.
To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.

When I click on the link: DocumentTemplateChanger extension I get a “Page not found” error. Has the link been changed?
Thanks

You’re right. It looks like the extensions site underwent a drastic URL reorganisation. I fix the link.