/usr/share/doc/pelican-doc/html/content.html is in pelican-doc 3.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Writing content — Pelican 3.7.1 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '3.7.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="Pelican 3.7.1 documentation" href="index.html" />
<link rel="next" title="Publish your site" href="publish.html" />
<link rel="prev" title="Installing Pelican" href="install.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="publish.html" title="Publish your site"
accesskey="N">next</a></li>
<li class="right" >
<a href="install.html" title="Installing Pelican"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Pelican 3.7.1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="writing-content">
<h1>Writing content<a class="headerlink" href="#writing-content" title="Permalink to this headline">¶</a></h1>
<div class="section" id="articles-and-pages">
<h2>Articles and pages<a class="headerlink" href="#articles-and-pages" title="Permalink to this headline">¶</a></h2>
<p>Pelican considers “articles” to be chronological content, such as posts on a
blog, and thus associated with a date.</p>
<p>The idea behind “pages” is that they are usually not temporal in nature and are
used for content that does not change very often (e.g., “About” or “Contact”
pages).</p>
<p>You can find sample content in the repository at: <code class="docutils literal"><span class="pre">pelican/samples/content/</span></code></p>
</div>
<div class="section" id="file-metadata">
<span id="internal-metadata"></span><h2>File metadata<a class="headerlink" href="#file-metadata" title="Permalink to this headline">¶</a></h2>
<p>Pelican tries to be smart enough to get the information it needs from the
file system (for instance, about the category of your articles), but some
information you need to provide in the form of metadata inside your files.</p>
<p>If you are writing your content in reStructuredText format, you can provide
this metadata in text files via the following syntax (give your file the
<code class="docutils literal"><span class="pre">.rst</span></code> extension):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">My</span> <span class="nb">super</span> <span class="n">title</span>
<span class="c1">##############</span>
<span class="p">:</span><span class="n">date</span><span class="p">:</span> <span class="mi">2010</span><span class="o">-</span><span class="mi">10</span><span class="o">-</span><span class="mi">03</span> <span class="mi">10</span><span class="p">:</span><span class="mi">20</span>
<span class="p">:</span><span class="n">modified</span><span class="p">:</span> <span class="mi">2010</span><span class="o">-</span><span class="mi">10</span><span class="o">-</span><span class="mi">04</span> <span class="mi">18</span><span class="p">:</span><span class="mi">40</span>
<span class="p">:</span><span class="n">tags</span><span class="p">:</span> <span class="n">thats</span><span class="p">,</span> <span class="n">awesome</span>
<span class="p">:</span><span class="n">category</span><span class="p">:</span> <span class="n">yeah</span>
<span class="p">:</span><span class="n">slug</span><span class="p">:</span> <span class="n">my</span><span class="o">-</span><span class="nb">super</span><span class="o">-</span><span class="n">post</span>
<span class="p">:</span><span class="n">authors</span><span class="p">:</span> <span class="n">Alexis</span> <span class="n">Metaireau</span><span class="p">,</span> <span class="n">Conan</span> <span class="n">Doyle</span>
<span class="p">:</span><span class="n">summary</span><span class="p">:</span> <span class="n">Short</span> <span class="n">version</span> <span class="k">for</span> <span class="n">index</span> <span class="ow">and</span> <span class="n">feeds</span>
</pre></div>
</div>
<p>Author and tag lists may be semicolon-separated instead, which allows
you to write authors and tags containing commas:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">:</span><span class="n">tags</span><span class="p">:</span> <span class="n">pelican</span><span class="p">,</span> <span class="n">publishing</span> <span class="n">tool</span><span class="p">;</span> <span class="n">pelican</span><span class="p">,</span> <span class="n">bird</span>
<span class="p">:</span><span class="n">authors</span><span class="p">:</span> <span class="n">Metaireau</span><span class="p">,</span> <span class="n">Alexis</span><span class="p">;</span> <span class="n">Doyle</span><span class="p">,</span> <span class="n">Conan</span>
</pre></div>
</div>
<p>Pelican implements an extension to reStructuredText to enable support for the
<code class="docutils literal"><span class="pre">abbr</span></code> HTML tag. To use it, write something like this in your post:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>This will be turned into :abbr:`HTML (HyperText Markup Language)`.
</pre></div>
</div>
<p>You can also use Markdown syntax (with a file ending in <code class="docutils literal"><span class="pre">.md</span></code>,
<code class="docutils literal"><span class="pre">.markdown</span></code>, <code class="docutils literal"><span class="pre">.mkd</span></code>, or <code class="docutils literal"><span class="pre">.mdown</span></code>). Markdown generation requires that you
first explicitly install the <code class="docutils literal"><span class="pre">Markdown</span></code> package, which can be done via <code class="docutils literal"><span class="pre">pip</span>
<span class="pre">install</span> <span class="pre">Markdown</span></code>.</p>
<p>Pelican also supports <a class="reference external" href="http://pythonhosted.org/Markdown/extensions/">Markdown Extensions</a>, which might have to be installed
separately if they are not included in the default <code class="docutils literal"><span class="pre">Markdown</span></code> package and can
be configured and loaded via the <code class="docutils literal"><span class="pre">MARKDOWN</span></code> setting.</p>
<p>Metadata syntax for Markdown posts should follow this pattern:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Title</span><span class="p">:</span> <span class="n">My</span> <span class="nb">super</span> <span class="n">title</span>
<span class="n">Date</span><span class="p">:</span> <span class="mi">2010</span><span class="o">-</span><span class="mi">12</span><span class="o">-</span><span class="mi">03</span> <span class="mi">10</span><span class="p">:</span><span class="mi">20</span>
<span class="n">Modified</span><span class="p">:</span> <span class="mi">2010</span><span class="o">-</span><span class="mi">12</span><span class="o">-</span><span class="mi">05</span> <span class="mi">19</span><span class="p">:</span><span class="mi">30</span>
<span class="n">Category</span><span class="p">:</span> <span class="n">Python</span>
<span class="n">Tags</span><span class="p">:</span> <span class="n">pelican</span><span class="p">,</span> <span class="n">publishing</span>
<span class="n">Slug</span><span class="p">:</span> <span class="n">my</span><span class="o">-</span><span class="nb">super</span><span class="o">-</span><span class="n">post</span>
<span class="n">Authors</span><span class="p">:</span> <span class="n">Alexis</span> <span class="n">Metaireau</span><span class="p">,</span> <span class="n">Conan</span> <span class="n">Doyle</span>
<span class="n">Summary</span><span class="p">:</span> <span class="n">Short</span> <span class="n">version</span> <span class="k">for</span> <span class="n">index</span> <span class="ow">and</span> <span class="n">feeds</span>
<span class="n">This</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">content</span> <span class="n">of</span> <span class="n">my</span> <span class="nb">super</span> <span class="n">blog</span> <span class="n">post</span><span class="o">.</span>
</pre></div>
</div>
<p>Readers for additional formats (such as <a class="reference external" href="http://www.methods.co.nz/asciidoc/">AsciiDoc</a>) are available via plugins.
Refer to <a class="reference external" href="http://github.com/getpelican/pelican-plugins">pelican-plugins</a> repository for those.</p>
<p>Pelican can also process HTML files ending in <code class="docutils literal"><span class="pre">.html</span></code> and <code class="docutils literal"><span class="pre">.htm</span></code>. Pelican
interprets the HTML in a very straightforward manner, reading metadata from
<code class="docutils literal"><span class="pre">meta</span></code> tags, the title from the <code class="docutils literal"><span class="pre">title</span></code> tag, and the body out from the
<code class="docutils literal"><span class="pre">body</span></code> tag:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">html</span><span class="o">></span>
<span class="o"><</span><span class="n">head</span><span class="o">></span>
<span class="o"><</span><span class="n">title</span><span class="o">></span><span class="n">My</span> <span class="nb">super</span> <span class="n">title</span><span class="o"></</span><span class="n">title</span><span class="o">></span>
<span class="o"><</span><span class="n">meta</span> <span class="n">name</span><span class="o">=</span><span class="s2">"tags"</span> <span class="n">content</span><span class="o">=</span><span class="s2">"thats, awesome"</span> <span class="o">/></span>
<span class="o"><</span><span class="n">meta</span> <span class="n">name</span><span class="o">=</span><span class="s2">"date"</span> <span class="n">content</span><span class="o">=</span><span class="s2">"2012-07-09 22:28"</span> <span class="o">/></span>
<span class="o"><</span><span class="n">meta</span> <span class="n">name</span><span class="o">=</span><span class="s2">"modified"</span> <span class="n">content</span><span class="o">=</span><span class="s2">"2012-07-10 20:14"</span> <span class="o">/></span>
<span class="o"><</span><span class="n">meta</span> <span class="n">name</span><span class="o">=</span><span class="s2">"category"</span> <span class="n">content</span><span class="o">=</span><span class="s2">"yeah"</span> <span class="o">/></span>
<span class="o"><</span><span class="n">meta</span> <span class="n">name</span><span class="o">=</span><span class="s2">"authors"</span> <span class="n">content</span><span class="o">=</span><span class="s2">"Alexis Métaireau, Conan Doyle"</span> <span class="o">/></span>
<span class="o"><</span><span class="n">meta</span> <span class="n">name</span><span class="o">=</span><span class="s2">"summary"</span> <span class="n">content</span><span class="o">=</span><span class="s2">"Short version for index and feeds"</span> <span class="o">/></span>
<span class="o"></</span><span class="n">head</span><span class="o">></span>
<span class="o"><</span><span class="n">body</span><span class="o">></span>
<span class="n">This</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">content</span> <span class="n">of</span> <span class="n">my</span> <span class="nb">super</span> <span class="n">blog</span> <span class="n">post</span><span class="o">.</span>
<span class="o"></</span><span class="n">body</span><span class="o">></span>
<span class="o"></</span><span class="n">html</span><span class="o">></span>
</pre></div>
</div>
<p>With HTML, there is one simple exception to the standard metadata: <code class="docutils literal"><span class="pre">tags</span></code> can
be specified either via the <code class="docutils literal"><span class="pre">tags</span></code> metadata, as is standard in Pelican, or
via the <code class="docutils literal"><span class="pre">keywords</span></code> metadata, as is standard in HTML. The two can be used
interchangeably.</p>
<p>Note that, aside from the title, none of this article metadata is mandatory:
if the date is not specified and <code class="docutils literal"><span class="pre">DEFAULT_DATE</span></code> is set to <code class="docutils literal"><span class="pre">'fs'</span></code>, Pelican
will rely on the file’s “mtime” timestamp, and the category can be determined
by the directory in which the file resides. For example, a file located at
<code class="docutils literal"><span class="pre">python/foobar/myfoobar.rst</span></code> will have a category of <code class="docutils literal"><span class="pre">foobar</span></code>. If you would
like to organize your files in other ways where the name of the subfolder would
not be a good category name, you can set the setting <code class="docutils literal"><span class="pre">USE_FOLDER_AS_CATEGORY</span></code>
to <code class="docutils literal"><span class="pre">False</span></code>. When parsing dates given in the page metadata, Pelican supports
the W3C’s <a class="reference external" href="http://www.w3.org/TR/NOTE-datetime">suggested subset ISO 8601</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When experimenting with different settings (especially the metadata
ones) caching may interfere and the changes may not be visible. In
such cases disable caching with <code class="docutils literal"><span class="pre">LOAD_CONTENT_CACHE</span> <span class="pre">=</span> <span class="pre">False</span></code> or
use the <code class="docutils literal"><span class="pre">--ignore-cache</span></code> command-line switch.</p>
</div>
<p><code class="docutils literal"><span class="pre">modified</span></code> should be last time you updated the article, and defaults to <code class="docutils literal"><span class="pre">date</span></code> if not specified.
Besides you can show <code class="docutils literal"><span class="pre">modified</span></code> in the templates, feed entries in feed readers will be updated automatically
when you set <code class="docutils literal"><span class="pre">modified</span></code> to the current date after you modified your article.</p>
<p><code class="docutils literal"><span class="pre">authors</span></code> is a comma-separated list of article authors. If there’s only one author you
can use <code class="docutils literal"><span class="pre">author</span></code> field.</p>
<p>If you do not explicitly specify summary metadata for a given post, the
<code class="docutils literal"><span class="pre">SUMMARY_MAX_LENGTH</span></code> setting can be used to specify how many words from the
beginning of an article are used as the summary.</p>
<p>You can also extract any metadata from the filename through a regular
expression to be set in the <code class="docutils literal"><span class="pre">FILENAME_METADATA</span></code> setting. All named groups
that are matched will be set in the metadata object. The default value for the
<code class="docutils literal"><span class="pre">FILENAME_METADATA</span></code> setting will only extract the date from the filename. For
example, if you would like to extract both the date and the slug, you could set
something like: <code class="docutils literal"><span class="pre">'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'</span></code></p>
<p>Please note that the metadata available inside your files takes precedence over
the metadata extracted from the filename.</p>
</div>
<div class="section" id="pages">
<h2>Pages<a class="headerlink" href="#pages" title="Permalink to this headline">¶</a></h2>
<p>If you create a folder named <code class="docutils literal"><span class="pre">pages</span></code> inside the content folder, all the
files in it will be used to generate static pages, such as <strong>About</strong> or
<strong>Contact</strong> pages. (See example filesystem layout below.)</p>
<p>You can use the <code class="docutils literal"><span class="pre">DISPLAY_PAGES_ON_MENU</span></code> setting to control whether all those
pages are displayed in the primary navigation menu. (Default is <code class="docutils literal"><span class="pre">True</span></code>.)</p>
<p>If you want to exclude any pages from being linked to or listed in the menu
then add a <code class="docutils literal"><span class="pre">status:</span> <span class="pre">hidden</span></code> attribute to its metadata. This is useful for
things like making error pages that fit the generated theme of your site.</p>
</div>
<div class="section" id="linking-to-internal-content">
<span id="ref-linking-to-internal-content"></span><h2>Linking to internal content<a class="headerlink" href="#linking-to-internal-content" title="Permalink to this headline">¶</a></h2>
<p>From Pelican 3.1 onwards, it is now possible to specify intra-site links to
files in the <em>source content</em> hierarchy instead of files in the <em>generated</em>
hierarchy. This makes it easier to link from the current post to other content
that may be sitting alongside that post (instead of having to determine where
the other content will be placed after site generation).</p>
<p>To link to internal content (files in the <code class="docutils literal"><span class="pre">content</span></code> directory), use the
following syntax for the link target: <code class="docutils literal"><span class="pre">{filename}path/to/file</span></code>
Note: forward slashes, <code class="docutils literal"><span class="pre">/</span></code>,
are the required path separator in the <code class="docutils literal"><span class="pre">{filename}</span></code> directive
on all operating systems, including Windows.</p>
<p>For example, a Pelican project might be structured like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>website/
├── content
│ ├── category/
│ │ └── article1.rst
│ ├── article2.md
│ └── pages
│ └── about.md
└── pelican.conf.py
</pre></div>
</div>
<p>In this example, <code class="docutils literal"><span class="pre">article1.rst</span></code> could look like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>The first article
#################
:date: 2012-12-01 10:02
See below intra-site link examples in reStructuredText format.
`a link relative to the current file <{filename}../article2.md>`_
`a link relative to the content root <{filename}/article2.md>`_
</pre></div>
</div>
<p>and <code class="docutils literal"><span class="pre">article2.md</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Title</span><span class="p">:</span> <span class="n">The</span> <span class="n">second</span> <span class="n">article</span>
<span class="n">Date</span><span class="p">:</span> <span class="mi">2012</span><span class="o">-</span><span class="mi">12</span><span class="o">-</span><span class="mi">01</span> <span class="mi">10</span><span class="p">:</span><span class="mi">02</span>
<span class="n">See</span> <span class="n">below</span> <span class="n">intra</span><span class="o">-</span><span class="n">site</span> <span class="n">link</span> <span class="n">examples</span> <span class="ow">in</span> <span class="n">Markdown</span> <span class="nb">format</span><span class="o">.</span>
<span class="p">[</span><span class="n">a</span> <span class="n">link</span> <span class="n">relative</span> <span class="n">to</span> <span class="n">the</span> <span class="n">current</span> <span class="n">file</span><span class="p">]({</span><span class="n">filename</span><span class="p">}</span><span class="n">category</span><span class="o">/</span><span class="n">article1</span><span class="o">.</span><span class="n">rst</span><span class="p">)</span>
<span class="p">[</span><span class="n">a</span> <span class="n">link</span> <span class="n">relative</span> <span class="n">to</span> <span class="n">the</span> <span class="n">content</span> <span class="n">root</span><span class="p">]({</span><span class="n">filename</span><span class="p">}</span><span class="o">/</span><span class="n">category</span><span class="o">/</span><span class="n">article1</span><span class="o">.</span><span class="n">rst</span><span class="p">)</span>
</pre></div>
</div>
<div class="section" id="linking-to-static-files">
<h3>Linking to static files<a class="headerlink" href="#linking-to-static-files" title="Permalink to this headline">¶</a></h3>
<p>Linking to non-article or non-page content uses the same <code class="docutils literal"><span class="pre">{filename}</span></code> syntax
as described above. It is important to remember that those files will not be
copied to the output directory unless the source directories containing them
are included in the <code class="docutils literal"><span class="pre">STATIC_PATHS</span></code> setting of the project’s <code class="docutils literal"><span class="pre">pelicanconf.py</span></code>
file. Pelican’s default configuration includes the <code class="docutils literal"><span class="pre">images</span></code> directory for
this, but others must be added manually. Forgetting to do so will result in
broken links.</p>
<p>For example, a project’s content directory might be structured like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>content
├── images
│ └── han.jpg
├── pdfs
│ └── menu.pdf
└── pages
└── test.md
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">test.md</span></code> would include:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>![Alt Text]({filename}/images/han.jpg)
[Our Menu]({filename}/pdfs/menu.pdf)
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">pelicanconf.py</span></code> would include:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">STATIC_PATHS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'images'</span><span class="p">,</span> <span class="s1">'pdfs'</span><span class="p">]</span>
</pre></div>
</div>
<p>Site generation would then copy <code class="docutils literal"><span class="pre">han.jpg</span></code> to <code class="docutils literal"><span class="pre">output/images/han.jpg</span></code>,
<code class="docutils literal"><span class="pre">menu.pdf</span></code> to <code class="docutils literal"><span class="pre">output/pdfs/menu.pdf</span></code>, and write the appropriate links
in <code class="docutils literal"><span class="pre">test.md</span></code>.</p>
</div>
<div class="section" id="mixed-content-in-the-same-directory">
<h3>Mixed content in the same directory<a class="headerlink" href="#mixed-content-in-the-same-directory" title="Permalink to this headline">¶</a></h3>
<p>Starting with Pelican 3.5, static files can safely share a source directory with
page source files, without exposing the page sources in the generated site.
Any such directory must be added to both <code class="docutils literal"><span class="pre">STATIC_PATHS</span></code> and <code class="docutils literal"><span class="pre">PAGE_PATHS</span></code>
(or <code class="docutils literal"><span class="pre">STATIC_PATHS</span></code> and <code class="docutils literal"><span class="pre">ARTICLE_PATHS</span></code>). Pelican will identify and process
the page source files normally, and copy the remaining files as if they lived
in a separate directory reserved for static files.</p>
<p>Note: Placing static and content source files together in the same source
directory does not guarantee that they will end up in the same place in the
generated site. The easiest way to do this is by using the <code class="docutils literal"><span class="pre">{attach}</span></code> link
syntax (described below). Alternatively, the <code class="docutils literal"><span class="pre">STATIC_SAVE_AS</span></code>,
<code class="docutils literal"><span class="pre">PAGE_SAVE_AS</span></code>, and <code class="docutils literal"><span class="pre">ARTICLE_SAVE_AS</span></code> settings (and the corresponding
<code class="docutils literal"><span class="pre">*_URL</span></code> settings) can be configured to place files of different types
together, just as they could in earlier versions of Pelican.</p>
</div>
<div class="section" id="attaching-static-files">
<h3>Attaching static files<a class="headerlink" href="#attaching-static-files" title="Permalink to this headline">¶</a></h3>
<p>Starting with Pelican 3.5, static files can be “attached” to a page or article
using this syntax for the link target: <code class="docutils literal"><span class="pre">{attach}path/to/file</span></code> This works
like the <code class="docutils literal"><span class="pre">{filename}</span></code> syntax, but also relocates the static file into the
linking document’s output directory. If the static file originates from a
subdirectory beneath the linking document’s source, that relationship will be
preserved on output. Otherwise, it will become a sibling of the linking
document.</p>
<p>This only works for linking to static files, and only when they originate from
a directory included in the <code class="docutils literal"><span class="pre">STATIC_PATHS</span></code> setting.</p>
<p>For example, a project’s content directory might be structured like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>content
├── blog
│ ├── icons
│ │ └── icon.png
│ ├── photo.jpg
│ └── testpost.md
└── downloads
└── archive.zip
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">pelicanconf.py</span></code> would include:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">PATH</span> <span class="o">=</span> <span class="s1">'content'</span>
<span class="n">STATIC_PATHS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'blog'</span><span class="p">,</span> <span class="s1">'downloads'</span><span class="p">]</span>
<span class="n">ARTICLE_PATHS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'blog'</span><span class="p">]</span>
<span class="n">ARTICLE_SAVE_AS</span> <span class="o">=</span> <span class="s1">'{date:%Y}/</span><span class="si">{slug}</span><span class="s1">.html'</span>
<span class="n">ARTICLE_URL</span> <span class="o">=</span> <span class="s1">'{date:%Y}/</span><span class="si">{slug}</span><span class="s1">.html'</span>
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">testpost.md</span></code> would include:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>Title: Test Post
Category: test
Date: 2014-10-31
![Icon]({attach}icons/icon.png)
![Photo]({attach}photo.jpg)
[Downloadable File]({attach}/downloads/archive.zip)
</pre></div>
</div>
<p>Site generation would then produce an output directory structured like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>output
└── 2014
├── archive.zip
├── icons
│ └── icon.png
├── photo.jpg
└── test-post.html
</pre></div>
</div>
<p>Notice that all the files linked using <code class="docutils literal"><span class="pre">{attach}</span></code> ended up in or beneath
the article’s output directory.</p>
<p>If a static file is linked multiple times, the relocating feature of
<code class="docutils literal"><span class="pre">{attach}</span></code> will only work in the first of those links to be processed.
After the first link, Pelican will treat <code class="docutils literal"><span class="pre">{attach}</span></code> like <code class="docutils literal"><span class="pre">{filename}</span></code>.
This avoids breaking the already-processed links.</p>
<p><strong>Be careful when linking to a file from multiple documents:</strong>
Since the first link to a file finalizes its location and Pelican does
not define the order in which documents are processed, using <code class="docutils literal"><span class="pre">{attach}</span></code> on a
file linked by multiple documents can cause its location to change from one
site build to the next. (Whether this happens in practice will depend on the
operating system, file system, version of Pelican, and documents being added,
modified, or removed from the project.) Any external sites linking to the
file’s old location might then find their links broken. <strong>It is therefore
advisable to use {attach} only if you use it in all links to a file, and only
if the linking documents share a single directory.</strong> Under these conditions,
the file’s output location will not change in future builds. In cases where
these precautions are not possible, consider using <code class="docutils literal"><span class="pre">{filename}</span></code> links instead
of <code class="docutils literal"><span class="pre">{attach}</span></code>, and letting the file’s location be determined by the project’s
<code class="docutils literal"><span class="pre">STATIC_SAVE_AS</span></code> and <code class="docutils literal"><span class="pre">STATIC_URL</span></code> settings. (Per-file <code class="docutils literal"><span class="pre">save_as</span></code> and
<code class="docutils literal"><span class="pre">url</span></code> overrides can still be set in <code class="docutils literal"><span class="pre">EXTRA_PATH_METADATA</span></code>.)</p>
</div>
<div class="section" id="linking-to-authors-categories-index-and-tags">
<h3>Linking to authors, categories, index and tags<a class="headerlink" href="#linking-to-authors-categories-index-and-tags" title="Permalink to this headline">¶</a></h3>
<p>You can link to authors, categories, index and tags using the <code class="docutils literal"><span class="pre">{author}name</span></code>,
<code class="docutils literal"><span class="pre">{category}foobar</span></code>, <code class="docutils literal"><span class="pre">{index}</span></code> and <code class="docutils literal"><span class="pre">{tag}tagname</span></code> syntax.</p>
</div>
<div class="section" id="deprecated-internal-link-syntax">
<h3>Deprecated internal link syntax<a class="headerlink" href="#deprecated-internal-link-syntax" title="Permalink to this headline">¶</a></h3>
<p>To remain compatible with earlier versions, Pelican still supports vertical bars
(<code class="docutils literal"><span class="pre">||</span></code>) in addition to curly braces (<code class="docutils literal"><span class="pre">{}</span></code>) for internal links. For example:
<code class="docutils literal"><span class="pre">|filename|an_article.rst</span></code>, <code class="docutils literal"><span class="pre">|tag|tagname</span></code>, <code class="docutils literal"><span class="pre">|category|foobar</span></code>.
The syntax was changed from <code class="docutils literal"><span class="pre">||</span></code> to <code class="docutils literal"><span class="pre">{}</span></code> to avoid collision with Markdown
extensions or reST directives. Support for the old syntax may eventually be
removed.</p>
</div>
</div>
<div class="section" id="importing-an-existing-site">
<h2>Importing an existing site<a class="headerlink" href="#importing-an-existing-site" title="Permalink to this headline">¶</a></h2>
<p>It is possible to import your site from WordPress, Tumblr, Dotclear, and RSS
feeds using a simple script. See <a class="reference internal" href="importer.html#import"><span class="std std-ref">Importing an existing site</span></a>.</p>
</div>
<div class="section" id="translations">
<h2>Translations<a class="headerlink" href="#translations" title="Permalink to this headline">¶</a></h2>
<p>It is possible to translate articles. To do so, you need to add a <code class="docutils literal"><span class="pre">lang</span></code> meta
attribute to your articles/pages and set a <code class="docutils literal"><span class="pre">DEFAULT_LANG</span></code> setting (which is
English [en] by default). With those settings in place, only articles with the
default language will be listed, and each article will be accompanied by a list
of available translations for that article.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This core Pelican functionality does not create sub-sites
(e.g. <code class="docutils literal"><span class="pre">example.com/de</span></code>) with translated templates for each
language. For such advanced functionality the <a class="reference external" href="http://github.com/getpelican/pelican-plugins/tree/master/i18n_subsites">i18n_subsites
plugin</a> can be used.</p>
</div>
<p>Pelican uses the article’s URL “slug” to determine if two or more articles are
translations of one another. The slug can be set manually in the file’s
metadata; if not set explicitly, Pelican will auto-generate the slug from the
title of the article.</p>
<p>Here is an example of two articles, one in English and the other in French.</p>
<p>The English article:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Foobar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">dead</span>
<span class="c1">##################</span>
<span class="p">:</span><span class="n">slug</span><span class="p">:</span> <span class="n">foobar</span><span class="o">-</span><span class="ow">is</span><span class="o">-</span><span class="ow">not</span><span class="o">-</span><span class="n">dead</span>
<span class="p">:</span><span class="n">lang</span><span class="p">:</span> <span class="n">en</span>
<span class="n">That</span><span class="s1">'s true, foobar is still alive!</span>
</pre></div>
</div>
<p>And the French version:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>Foobar n'est pas mort !
#######################
:slug: foobar-is-not-dead
:lang: fr
Oui oui, foobar est toujours vivant !
</pre></div>
</div>
<p>Post content quality notwithstanding, you can see that only item in common
between the two articles is the slug, which is functioning here as an
identifier. If you’d rather not explicitly define the slug this way, you must
then instead ensure that the translated article titles are identical, since the
slug will be auto-generated from the article title.</p>
<p>If you do not want the original version of one specific article to be detected
by the <code class="docutils literal"><span class="pre">DEFAULT_LANG</span></code> setting, use the <code class="docutils literal"><span class="pre">translation</span></code> metadata to specify
which posts are translations:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Foobar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">dead</span>
<span class="c1">##################</span>
<span class="p">:</span><span class="n">slug</span><span class="p">:</span> <span class="n">foobar</span><span class="o">-</span><span class="ow">is</span><span class="o">-</span><span class="ow">not</span><span class="o">-</span><span class="n">dead</span>
<span class="p">:</span><span class="n">lang</span><span class="p">:</span> <span class="n">en</span>
<span class="p">:</span><span class="n">translation</span><span class="p">:</span> <span class="n">true</span>
<span class="n">That</span><span class="s1">'s true, foobar is still alive!</span>
</pre></div>
</div>
</div>
<div class="section" id="syntax-highlighting">
<span id="internal-pygments-options"></span><h2>Syntax highlighting<a class="headerlink" href="#syntax-highlighting" title="Permalink to this headline">¶</a></h2>
<p>Pelican can provide colorized syntax highlighting for your code blocks.
To do so, you must use the following conventions inside your content files.</p>
<p>For reStructuredText, use the <code class="docutils literal"><span class="pre">code-block</span></code> directive to specify the type
of code to be highlighted (in these examples, we’ll use <code class="docutils literal"><span class="pre">python</span></code>):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">..</span> <span class="n">code</span><span class="o">-</span><span class="n">block</span><span class="p">::</span> <span class="n">python</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Pelican is a static site generator."</span><span class="p">)</span>
</pre></div>
</div>
<p>For Markdown, which utilizes the <a class="reference external" href="http://pythonhosted.org/Markdown/extensions/code_hilite.html#syntax">CodeHilite extension</a> to provide syntax
highlighting, include the language identifier just above the code block,
indenting both the identifier and the code:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">There</span> <span class="n">are</span> <span class="n">two</span> <span class="n">ways</span> <span class="n">to</span> <span class="n">specify</span> <span class="n">the</span> <span class="n">identifier</span><span class="p">:</span>
<span class="p">:::</span><span class="n">python</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"The triple-colon syntax will *not* show line numbers."</span><span class="p">)</span>
<span class="n">To</span> <span class="n">display</span> <span class="n">line</span> <span class="n">numbers</span><span class="p">,</span> <span class="n">use</span> <span class="n">a</span> <span class="n">path</span><span class="o">-</span><span class="n">less</span> <span class="n">shebang</span> <span class="n">instead</span> <span class="n">of</span> <span class="n">colons</span><span class="p">:</span>
<span class="c1">#!python</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"The path-less shebang syntax *will* show line numbers."</span><span class="p">)</span>
</pre></div>
</div>
<p>The specified identifier (e.g. <code class="docutils literal"><span class="pre">python</span></code>, <code class="docutils literal"><span class="pre">ruby</span></code>) should be one that
appears on the <a class="reference external" href="http://pygments.org/docs/lexers/">list of available lexers</a>.</p>
<p>When using reStructuredText the following options are available in the
code-block directive:</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="18%" />
<col width="62%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Option</th>
<th class="head">Valid values</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>anchorlinenos</td>
<td>N/A</td>
<td>If present wrap line numbers in <a> tags.</td>
</tr>
<tr class="row-odd"><td>classprefix</td>
<td>string</td>
<td>String to prepend to token class names</td>
</tr>
<tr class="row-even"><td>hl_lines</td>
<td>numbers</td>
<td>List of lines to be highlighted, where
line numbers to highlight are separated
by a space. This is similar to
<code class="docutils literal"><span class="pre">emphasize-lines</span></code> in Sphinx, but it
does not support a range of line numbers
separated by a hyphen, or comma-separated
line numbers.</td>
</tr>
<tr class="row-odd"><td>lineanchors</td>
<td>string</td>
<td>Wrap each line in an anchor using this
string and -linenumber.</td>
</tr>
<tr class="row-even"><td>linenos</td>
<td>string</td>
<td>If present or set to “table” output line
numbers in a table, if set to
“inline” output them inline. “none” means
do not output the line numbers for this
table.</td>
</tr>
<tr class="row-odd"><td>linenospecial</td>
<td>number</td>
<td>If set every nth line will be given the
‘special’ css class.</td>
</tr>
<tr class="row-even"><td>linenostart</td>
<td>number</td>
<td>Line number for the first line.</td>
</tr>
<tr class="row-odd"><td>linenostep</td>
<td>number</td>
<td>Print every nth line number.</td>
</tr>
<tr class="row-even"><td>lineseparator</td>
<td>string</td>
<td>String to print between lines of code,
‘n’ by default.</td>
</tr>
<tr class="row-odd"><td>linespans</td>
<td>string</td>
<td>Wrap each line in a span using this and
-linenumber.</td>
</tr>
<tr class="row-even"><td>nobackground</td>
<td>N/A</td>
<td>If set do not output background color for
the wrapping element</td>
</tr>
<tr class="row-odd"><td>nowrap</td>
<td>N/A</td>
<td>If set do not wrap the tokens at all.</td>
</tr>
<tr class="row-even"><td>tagsfile</td>
<td>string</td>
<td>ctags file to use for name definitions.</td>
</tr>
<tr class="row-odd"><td>tagurlformat</td>
<td>string</td>
<td>format for the ctag links.</td>
</tr>
</tbody>
</table>
<p>Note that, depending on the version, your Pygments module might not have
all of these options available. Refer to the <em>HtmlFormatter</em> section of the
<a class="reference external" href="http://pygments.org/docs/formatters/">Pygments documentation</a> for more
details on each of the options.</p>
<p>For example, the following code block enables line numbers, starting at 153,
and prefixes the Pygments CSS classes with <em>pgcss</em> to make the names
more unique and avoid possible CSS conflicts:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">..</span> <span class="n">code</span><span class="o">-</span><span class="n">block</span><span class="p">::</span> <span class="n">identifier</span>
<span class="p">:</span><span class="n">classprefix</span><span class="p">:</span> <span class="n">pgcss</span>
<span class="p">:</span><span class="n">linenos</span><span class="p">:</span> <span class="n">table</span>
<span class="p">:</span><span class="n">linenostart</span><span class="p">:</span> <span class="mi">153</span>
<span class="o"><</span><span class="n">indented</span> <span class="n">code</span> <span class="n">block</span> <span class="n">goes</span> <span class="n">here</span><span class="o">></span>
</pre></div>
</div>
<p>It is also possible to specify the <code class="docutils literal"><span class="pre">PYGMENTS_RST_OPTIONS</span></code> variable in your
Pelican settings file to include options that will be automatically applied to
every code block.</p>
<p>For example, if you want to have line numbers displayed for every code block
and a CSS prefix you would set this variable to:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">PYGMENTS_RST_OPTIONS</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'classprefix'</span><span class="p">:</span> <span class="s1">'pgcss'</span><span class="p">,</span> <span class="s1">'linenos'</span><span class="p">:</span> <span class="s1">'table'</span><span class="p">}</span>
</pre></div>
</div>
<p>If specified, settings for individual code blocks will override the defaults in
your settings file.</p>
</div>
<div class="section" id="publishing-drafts">
<h2>Publishing drafts<a class="headerlink" href="#publishing-drafts" title="Permalink to this headline">¶</a></h2>
<p>If you want to publish an article as a draft (for friends to review before
publishing, for example), you can add a <code class="docutils literal"><span class="pre">Status:</span> <span class="pre">draft</span></code> attribute to its
metadata. That article will then be output to the <code class="docutils literal"><span class="pre">drafts</span></code> folder and not
listed on the index page nor on any category or tag page.</p>
<p>If your articles should be automatically published as a draft (to not accidentally
publish an article before it is finished) include the status in the <code class="docutils literal"><span class="pre">DEFAULT_METADATA</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">DEFAULT_METADATA</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">'status'</span><span class="p">:</span> <span class="s1">'draft'</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
<p>To publish a post when the default status is <code class="docutils literal"><span class="pre">draft</span></code>, update the post’s
metadata to include <code class="docutils literal"><span class="pre">Status:</span> <span class="pre">published</span></code>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Writing content</a><ul>
<li><a class="reference internal" href="#articles-and-pages">Articles and pages</a></li>
<li><a class="reference internal" href="#file-metadata">File metadata</a></li>
<li><a class="reference internal" href="#pages">Pages</a></li>
<li><a class="reference internal" href="#linking-to-internal-content">Linking to internal content</a><ul>
<li><a class="reference internal" href="#linking-to-static-files">Linking to static files</a></li>
<li><a class="reference internal" href="#mixed-content-in-the-same-directory">Mixed content in the same directory</a></li>
<li><a class="reference internal" href="#attaching-static-files">Attaching static files</a></li>
<li><a class="reference internal" href="#linking-to-authors-categories-index-and-tags">Linking to authors, categories, index and tags</a></li>
<li><a class="reference internal" href="#deprecated-internal-link-syntax">Deprecated internal link syntax</a></li>
</ul>
</li>
<li><a class="reference internal" href="#importing-an-existing-site">Importing an existing site</a></li>
<li><a class="reference internal" href="#translations">Translations</a></li>
<li><a class="reference internal" href="#syntax-highlighting">Syntax highlighting</a></li>
<li><a class="reference internal" href="#publishing-drafts">Publishing drafts</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="install.html"
title="previous chapter">Installing Pelican</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="publish.html"
title="next chapter">Publish your site</a></p>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="publish.html" title="Publish your site"
>next</a></li>
<li class="right" >
<a href="install.html" title="Installing Pelican"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Pelican 3.7.1 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2017, Alexis Metaireau and contributors.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9.
</div>
</body>
</html>
|