try adding a toc now that ikiwiki supports it
[ikiwiki] / doc / setup.mdwn
1 This tutorial will walk you through setting up a wiki with ikiwiki.
2
3 [[toc ]]
4
5 ### 1. [[Download]] and [[install]] ikiwiki.
6
7 ### 2. Decide where your wiki's files will go.
8
9 As a wiki compiler, ikiwiki builds a wiki from files in a source directory,
10 and outputs the files to a destination directory.  If you keep your wiki in
11 a version control system, the source directory will contain a working copy
12 checked out from the version control system.
13
14 For the purposes of this tutorial, we'll set shell variables
15 for these locations, and use those variables in the commands that follow.
16
17         SRCDIR=~/wikiwc
18         DESTDIR=~/public_html/wiki/
19
20 Note that ikiwiki owns the working copy directory; do not perform your own
21 edits in ikiwiki's working copy.
22
23 ### 3. Create the beginnings of your wiki.
24
25 This will create a simple main page for the wiki.
26
27         mkdir $SRCDIR
28         cd $SRCDIR
29         $EDITOR index.mdwn
30
31 In the editor, you could start by entering a simple page like
32 [[toggle id=page text="this one"]].
33 [[toggleable id=page text="""
34         Welcome to your new wiki.
35
36         All wikis are supposed to have a \[[SandBox]],
37         so this one does too.
38
39         ----
40
41         This wiki is powered by [ikiwiki](http://ikiwiki.info).
42 """]]
43    
44 See [[HelpOnFormatting]] for details about the markup language.
45
46 Note that several [[standard_wiki_pages|basewiki]] will be added to your
47 wiki, from files in `/usr/share/ikiwiki/basewiki/`, so your wiki will
48 automatically get a [[SandBox]], and some other useful pages.
49
50 ### 4. Build your wiki for the first time.
51
52         ikiwiki --verbose $SRCDIR $DESTDIR --url=http://example.org/~you/wiki/
53
54 Replace the url with the real url to your wiki. You should now
55 be able to visit the url and see your wiki.
56
57 ### 5. Add content to your wiki.
58
59 Repeat steps 3 and 4 as desired, editing or adding pages and rebuilding the
60 wiki.
61    
62 To quickly get started on a common task like blogging with ikiwiki, you
63 can copy in files from the [[examples]]. The examples are located in
64 `doc/examples/` in the ikiwiki source package.
65
66 You can experiment with other ikiwiki parameters such as `--wikiname`
67 and `--rebuild` too. Get comfortable with its command line (see
68 [[usage]]).
69
70 ### 6. Add a setup file.
71
72 By now you should be getting tired of typing in all the command line
73 options each time you change something in your wiki's setup. Time to
74 introduce setup files.
75    
76 A sample setup file is [[ikiwiki.setup]]. Download it (or copy it from
77 `doc/ikiwiki.setup` in the ikiwiki sources), and edit it. Note that this
78 file should *not* be put in your wiki's directory with the rest of the
79 files. A good place to put it is in a ~/.ikiwiki/ subdirectory.
80    
81 Most of the options, like `wikiname` in the setup file are the same as
82 ikiwiki's command line options (documented in [[usage]]. `srcdir` and
83 `destdir` are the two directories you specify when running ikiwiki by
84 hand. Make sure that these are pointing to the right directories, and
85 read through and configure the rest of the file to your liking.
86
87 When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it
88 will set everything up.
89
90 ### 7. Turn on additional features.
91
92 Now you have a basic wiki with a configuration file. Time to experiment
93 with ikiwiki's many features. 
94    
95 Let's first enable a key wiki feature and set up [[CGI]] to allow
96 editing the wiki from the web. Just edit ikiwiki.setup, uncomment the
97 block for the cgi wrapper, make sure the filename for the cgi wrapper
98 is ok, run `ikiwiki --setup ikiwiki.setup`, and you're done!
99
100 There are lots of other configuration options in ikiwiki.setup that you
101 can uncomment, configure, and enable by re-running
102 `ikiwiki --setup ikiwiki.setup`. Be sure to browse through all the
103 [[plugins]]..
104
105 ### 8. Put your wiki in revision control.
106
107 At this point you might want to check your wiki in to a revision control
108 system so you can keep track of changes and revert edits. Depending
109 on the revision control system you choose, the way this is done varies.
110
111 There's little that's ikiwiki specific about these instructions; this is
112 just how you put a directory under revision control using the various
113 systems that ikiwiki supports. Note that the .ikiwiki subdirectory is
114 where ikiwiki keeps its state, and should be preserved, but not checked
115 into revision control.
116
117 [[toggle id=subversion text="Subversion"]]
118 [[toggleable id=subversion text="""
119         REPOSITORY=~/wikirepo
120         svnadmin create $REPOSITORY
121         svn mkdir file://$REPOSITORY/trunk -m "create trunk"
122         cd $SRCDIR
123         svn co file://$REPOSITORY/trunk .
124         svn add *
125         svn commit -m "initial import"
126 """]]
127
128 [[toggle id=git text="Git"]]
129 [[toggleable id=git text="""
130 When using Git, you probably want to set up two repositories, of which
131 one should be bare (meaning that it does not have a working tree
132 checked out). We call the bare repository the "repository" and the
133 other will be the "srcdir" (which `ikiwiki` uses to compile the wiki).
134 There are [other
135 ways](http://blog.madduck.net/vcs/2007.07.11_publishing-git-repositories)
136 to do the following, but this might be easiest:
137
138         REPOSITORY=~/wiki.git
139         GIT_DIR=$REPOSITORY git --bare init --shared
140         cd $SRCDIR
141         git init
142         echo /.ikiwiki > .gitignore
143         git add .
144         git commit -m "initial commit"
145         git remote add origin $REPOSITORY
146         git config branch.master.merge refs/heads/master
147         git push --all
148
149 It is **paramount** that you **never** push to the Git repository in
150 `$SRCDIR` ([this FAQ entry explains
151 why](http://git.or.cz/gitwiki/GitFaq#head-b6a3d85f677763313159eb39f7dbf4579d4ee28b)).
152 Instead, if you want to work on the wiki from a remote machine, clone
153 `$REPOSITORY`, using either the `git` transport (if available), or
154 `ssh`.
155
156 If at any point you commit changes in `$SRCDIR`, make sure to `git
157 push` them to the `$REPOSITORY`. ikiwiki will do this automatically
158 for any changes made via the web.
159
160 Finally, see [[Git_pitfalls]] if you experience problems.
161 """]]
162
163 [[toggle id=tla text="TLA"]]
164 [[toggleable id=tla text="""
165         REPOSITORY=~/wikirepo
166         tla make-archive me@localhost--wiki $REPOSITORY
167         tla my-id "<me@localhost>"
168         cd $SRCDIR
169         tla archive-setup me@localhost--wiki/wiki--0
170         tla init-tree me@localhost--wiki/wiki--0
171         # Edit {arch}/=tagging-method and change the precious
172         # line to add the .ikiwiki directory to the regexp.
173         tla add *
174         tla import
175 """]]
176
177 [[toggle id=mercurial text="Mercurial"]]
178 [[toggleable id=mercurial text="""
179         REPOSITORY=$SRCDIR
180         hg init $REPOSITORY
181         cd $REPOSITORY
182         hg add *
183         hg commit -m "initial import"
184 """]]
185
186 [[toggle id=monotone text="Monotone"]]
187 [[toggleable id=monotone text="""
188         # These instructions are standard instructions to import a directory into monotone
189         # and set it up so that you don't need any passwords to use it
190         REPOSITORY=~/.ikiwiki/mtn.db
191         BRANCH=com.company.wikiname
192         # remember the password you use in the next step and
193         # substitute it for 'wikiKeyPass' in the get_passphrase() hook below
194         # note the you should never generate two monotone keys with the same name
195         mtn genkey web@machine.company.com
196         mtn db init --db=$REPOSITORY
197         mv $SRCDIR $SRCDIR-old
198         cd $SRCDIR-old
199         echo ".ikiwiki" > $SRCDIR-old/.mtn-ignore
200         mtn --db=$REPOSITORY --branch=$BRANCH import . -m "initial import"
201         cd ..
202         mtn --db=$REPOSITORY --branch=$BRANCH checkout $SRCDIR
203         mv $SRCDIR-old/.ikiwiki $SRCDIR
204         cat << EOF > $SRCDIR/_MTN/monotonerc
205         function get_passphrase (branchname)
206             return "wikiKeyPass"
207         end
208         EOF
209         rm -r $SRCDIR-old
210 """]]
211
212 ### 9. Configure ikiwiki to use revision control.
213
214 Once your wiki is checked in to the revision control system,
215 you should configure ikiwiki to use revision control. Edit your
216 ikiwiki.setup, and uncomment the lines for the revision control system
217 you chose to use. Be sure to set `svnrepo` to $REPOSITORY, if using
218 subversion. Uncomment the block for the wrapper for your revision
219 control system, and configure the wrapper path in that block
220 appropriately (for Git, it should be `$REPOSITORY/hooks/post-update`).
221
222 Once it's all set up, run `ikiwiki --setup ikiwiki.setup` once more.
223 Now you should be able to edit files in $SRCDIR, and use your revision
224 control system to commit them, and the wiki will automatically update.
225 And in the web interface, RecentChanges should work, and files changed
226 by web users will also be committed using revision control.
227
228 ### 10. Enjoy your new wiki!
229
230 Add yourself to [[IkiWikiUsers]]. And check out
231 the [[tips]] to find out how to get more out of ikiwiki.