move template documentation to the template directive
[ikiwiki] / doc / wikitemplates / discussion.mdwn
1 ## Place for local templates
2 Where does one put any locally modified templates for an individual ikiwiki? --Ivan Z.
3
4 > You can put them whereever you like; the `templatedir` controls
5 > where ikiwiki looks for them. --[[Joey]] 
6
7 Thank you for your response! My question arose out of my intention to make
8 custom templates for a wiki--specifically suited for the kind of  content
9 it will have--so, that would mean I would want to distribute them through
10 git together with other content of the wiki. So, for this case the
11 separation of conceptually ONE thing (the content, the templates, and the
12 config option which orders to use these templates) into THREE separate
13 files/repos (the main content repo, the repo with templates, and the config
14 file) is not convenient: instead of distributing a single repo, I have to
15 tell people to take three things if they want to replicate this wiki. How
16 would you solve this inconvenience? Perhaps, a default location of the
17 templates *inside* the source repo would do?--Ivan Z.
18
19 > I would avoid putting the templates in a subdirectory of the ikiwiki srcdir.
20 > (I'd also avoid putting the ikiwiki setup file there.)
21 > While it's safe to do either in some cases, there are configurations where
22 > it's unsafe. For example, a malicious user could use attachment handling to
23 > replace those files with their own, bad versions.
24
25 > So, two ideas for where to put the templatedir and ikiwiki setup. 
26
27 > * The easiest option is to put your wiki content in a subdirectory
28 >   ("wiki", say) and point `srcdir` at that.
29 >   then you can have another subdirectory for the wikitemplates,
30 >   and put the setup file at the top.
31 > * Another option if using git would be to have a separate branch,
32 >   in the same git repository, that holds wikitemplates and the setup file.
33 >   Then you check out the repository once to make the `srcdir` available,
34 >   and have a second checkout, of the other branch, to make the other stuff
35 >   available.
36
37 > Note that with either of these methods, you have to watch out if
38 > giving other direct commit access to the repository. They could
39 > still edit the setup file and templates, so only trusted users should
40 > be given access. (It is, however, perfectly safe to let people edit
41 > the wiki via the web, and is even safe to configure
42 > [[tips/untrusted_git_push]] to such a repository.) --[[Joey]]
43
44 Thanks, that's a nice and simple idea: to have a subdirectory! I'll try it. --Ivan Z.
45
46 A [[!taglink wish|wishlist]]: the ikiwiki program could be improved so that it follows the same logic as git in looking for its config: it could ascend directories until it finds an `.ikiwiki/` directory with `.ikiwiki/setup` and then uses that configuration. Now I'm tired to always type `ikiwiki --setup path/to/the/setup --refresh` when working in my working clone of the sources; I'd like to simply type `ikiwiki` instead, and let it find the setup file. The default location to look for templates could also be made to be a sibling of the setup file: `.ikiwiki/templates/`. --Ivan Z.