A new Riff-radio.org site with a static approach.

handbook.html 246KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>The Nikola Handbook | Riff</title>
  7. <link href="../assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
  8. <link rel="alternate" type="application/rss+xml" title="RSS" href="../rss.xml">
  9. <link rel="canonical" href="http://media.pagelibre.org/riff/site/pages/handbook.html">
  10. <link rel="icon" href="../favicon.ico" sizes="16x16">
  11. <!--[if lt IE 9]><script src="../assets/js/html5.js"></script><![endif]--><meta name="author" content="The Nikola Team">
  12. <meta property="og:site_name" content="Riff">
  13. <meta property="og:title" content="The Nikola Handbook">
  14. <meta property="og:url" content="http://media.pagelibre.org/riff/site/pages/handbook.html">
  15. <meta property="og:description" content="Version:
  16. 8.2.3
  17. Contents
  18. All You Need to Know
  19. What's Nikola and what can you do with it?
  20. Getting Help
  21. Why Static?
  22. Components
  23. Getting Started
  24. Creating a Blog Post
  25. Metadata fields
  26. Basic
  27. Extra
  28. Meta">
  29. <meta property="og:type" content="article">
  30. <meta property="article:published_time" content="2012-03-30T23:00:00-03:00">
  31. </head>
  32. <body>
  33. <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
  34. <!-- Menubar -->
  35. <div class="blog-masthead">
  36. <div class="container">
  37. <!-- This keeps the margins nice -->
  38. <nav class="blog-nav" role="navigation"><a href="../index.html" class="blog-nav-item">Accueil</a>
  39. <a href="about.html" class="blog-nav-item">About Riff</a>
  40. <a href="../rss.xml" class="blog-nav-item">RSS feed</a>
  41. </nav>
  42. </div>
  43. <!-- /.container -->
  44. </div>
  45. <!-- End of Menubar -->
  46. <div class="container" id="content" role="main">
  47. <div class="body-content">
  48. <div class="blog-header">
  49. <h1 class="blog-title">
  50. <a href="http://media.pagelibre.org/riff/site/">
  51. <span id="blog-title">Riff</span>
  52. </a>
  53. </h1>
  54. <p class="lead blog-description">Riff la radio rock</p>
  55. </div>
  56. <!--Body content-->
  57. <div class="row">
  58. <div class="col-sm-8 blog-main">
  59. <article class="post-text storypage" itemscope="itemscope" itemtype="http://schema.org/Article"><header><h2 class="p-name entry-title blog-post-title" itemprop="headline name"><a href="#" class="u-url">The Nikola Handbook</a></h2>
  60. </header><div class="e-content entry-content" itemprop="articleBody text">
  61. <dl class="docinfo simple">
  62. <dt class="version">Version<span class="colon">:</span>
  63. </dt>
  64. <dd class="version">8.2.3</dd>
  65. </dl>
  66. <nav class="contents alert alert-primary float-md-right" id="contents" role="doc-toc"><p class="topic-title">Contents</p>
  67. <ul class="simple">
  68. <li><p><a class="reference internal" href="handbook.html#all-you-need-to-know" id="toc-entry-1">All You Need to Know</a></p></li>
  69. <li><p><a class="reference internal" href="handbook.html#what-s-nikola-and-what-can-you-do-with-it" id="toc-entry-2">What's Nikola and what can you do with it?</a></p></li>
  70. <li><p><a class="reference internal" href="handbook.html#getting-help" id="toc-entry-3">Getting Help</a></p></li>
  71. <li><p><a class="reference internal" href="handbook.html#why-static" id="toc-entry-4">Why Static?</a></p></li>
  72. <li><p><a class="reference internal" href="handbook.html#components" id="toc-entry-5">Components</a></p></li>
  73. <li><p><a class="reference internal" href="handbook.html#getting-started" id="toc-entry-6">Getting Started</a></p></li>
  74. <li>
  75. <p><a class="reference internal" href="handbook.html#creating-a-blog-post" id="toc-entry-7">Creating a Blog Post</a></p>
  76. <ul>
  77. <li>
  78. <p><a class="reference internal" href="handbook.html#metadata-fields" id="toc-entry-8">Metadata fields</a></p>
  79. <ul>
  80. <li><p><a class="reference internal" href="handbook.html#basic" id="toc-entry-9">Basic</a></p></li>
  81. <li><p><a class="reference internal" href="handbook.html#extra" id="toc-entry-10">Extra</a></p></li>
  82. </ul>
  83. </li>
  84. <li>
  85. <p><a class="reference internal" href="handbook.html#metadata-formats" id="toc-entry-11">Metadata formats</a></p>
  86. <ul>
  87. <li><p><a class="reference internal" href="handbook.html#rest-style-comments" id="toc-entry-12">reST-style comments</a></p></li>
  88. <li><p><a class="reference internal" href="handbook.html#two-file-format" id="toc-entry-13">Two-file format</a></p></li>
  89. <li><p><a class="reference internal" href="handbook.html#jupyter-notebook-metadata" id="toc-entry-14">Jupyter Notebook metadata</a></p></li>
  90. <li><p><a class="reference internal" href="handbook.html#yaml-metadata" id="toc-entry-15">YAML metadata</a></p></li>
  91. <li><p><a class="reference internal" href="handbook.html#toml-metadata" id="toc-entry-16">TOML metadata</a></p></li>
  92. <li><p><a class="reference internal" href="handbook.html#rest-docinfo" id="toc-entry-17">reST docinfo</a></p></li>
  93. <li><p><a class="reference internal" href="handbook.html#pelican-markdown-metadata" id="toc-entry-18">Pelican/Markdown metadata</a></p></li>
  94. <li><p><a class="reference internal" href="handbook.html#html-meta-tags" id="toc-entry-19">HTML meta tags</a></p></li>
  95. <li><p><a class="reference internal" href="handbook.html#mapping-metadata-from-other-formats" id="toc-entry-20">Mapping metadata from other formats</a></p></li>
  96. </ul>
  97. </li>
  98. <li><p><a class="reference internal" href="handbook.html#multilingual-posts" id="toc-entry-21">Multilingual posts</a></p></li>
  99. <li><p><a class="reference internal" href="handbook.html#how-does-nikola-decide-where-posts-should-go" id="toc-entry-22">How does Nikola decide where posts should go?</a></p></li>
  100. <li><p><a class="reference internal" href="handbook.html#the-new-post-command" id="toc-entry-23">The <code class="docutils literal">new_post</code> command</a></p></li>
  101. <li><p><a class="reference internal" href="handbook.html#teasers" id="toc-entry-24">Teasers</a></p></li>
  102. <li><p><a class="reference internal" href="handbook.html#drafts" id="toc-entry-25">Drafts</a></p></li>
  103. <li><p><a class="reference internal" href="handbook.html#private-posts" id="toc-entry-26">Private Posts</a></p></li>
  104. <li><p><a class="reference internal" href="handbook.html#featured-posts" id="toc-entry-27">Featured Posts</a></p></li>
  105. <li><p><a class="reference internal" href="handbook.html#queuing-posts" id="toc-entry-28">Queuing Posts</a></p></li>
  106. <li><p><a class="reference internal" href="handbook.html#post-types" id="toc-entry-29">Post Types</a></p></li>
  107. <li>
  108. <p><a class="reference internal" href="handbook.html#indexes" id="toc-entry-30">Indexes</a></p>
  109. <ul>
  110. <li><p><a class="reference internal" href="handbook.html#settings" id="toc-entry-31">Settings</a></p></li>
  111. <li><p><a class="reference internal" href="handbook.html#static-indexes" id="toc-entry-32">Static indexes</a></p></li>
  112. </ul>
  113. </li>
  114. <li>
  115. <p><a class="reference internal" href="handbook.html#post-taxonomy" id="toc-entry-33">Post taxonomy</a></p>
  116. <ul>
  117. <li><p><a class="reference internal" href="handbook.html#tags" id="toc-entry-34">Tags</a></p></li>
  118. <li><p><a class="reference internal" href="handbook.html#categories" id="toc-entry-35">Categories</a></p></li>
  119. <li><p><a class="reference internal" href="handbook.html#configuring-tags-and-categories" id="toc-entry-36">Configuring tags and categories</a></p></li>
  120. </ul>
  121. </li>
  122. <li><p><a class="reference internal" href="handbook.html#what-if-i-dont-want-a-blog" id="toc-entry-37">What if I don’t want a blog?</a></p></li>
  123. </ul>
  124. </li>
  125. <li><p><a class="reference internal" href="handbook.html#creating-a-page" id="toc-entry-38">Creating a Page</a></p></li>
  126. <li>
  127. <p><a class="reference internal" href="handbook.html#supported-input-formats" id="toc-entry-39">Supported input formats</a></p>
  128. <ul>
  129. <li>
  130. <p><a class="reference internal" href="handbook.html#configuring-other-input-formats" id="toc-entry-40">Configuring other input formats</a></p>
  131. <ul>
  132. <li><p><a class="reference internal" href="handbook.html#markdown" id="toc-entry-41">Markdown</a></p></li>
  133. <li><p><a class="reference internal" href="handbook.html#jupyter-notebook" id="toc-entry-42">Jupyter Notebook</a></p></li>
  134. <li><p><a class="reference internal" href="handbook.html#html" id="toc-entry-43">HTML</a></p></li>
  135. <li><p><a class="reference internal" href="handbook.html#php" id="toc-entry-44">PHP</a></p></li>
  136. <li><p><a class="reference internal" href="handbook.html#pandoc" id="toc-entry-45">Pandoc</a></p></li>
  137. </ul>
  138. </li>
  139. </ul>
  140. </li>
  141. <li>
  142. <p><a class="reference internal" href="handbook.html#shortcodes" id="toc-entry-46">Shortcodes</a></p>
  143. <ul>
  144. <li><p><a class="reference internal" href="handbook.html#using-a-shortcode" id="toc-entry-47">Using a shortcode</a></p></li>
  145. <li><p><a class="reference internal" href="handbook.html#built-in-shortcodes" id="toc-entry-48">Built-in shortcodes</a></p></li>
  146. <li><p><a class="reference internal" href="handbook.html#community-shortcodes" id="toc-entry-49">Community shortcodes</a></p></li>
  147. <li><p><a class="reference internal" href="handbook.html#template-based-shortcodes" id="toc-entry-50">Template-based shortcodes</a></p></li>
  148. </ul>
  149. </li>
  150. <li><p><a class="reference internal" href="handbook.html#the-global-context-and-data-files" id="toc-entry-51">The Global Context and Data files</a></p></li>
  151. <li><p><a class="reference internal" href="handbook.html#redirections" id="toc-entry-52">Redirections</a></p></li>
  152. <li><p><a class="reference internal" href="handbook.html#configuration" id="toc-entry-53">Configuration</a></p></li>
  153. <li><p><a class="reference internal" href="handbook.html#customizing-your-site" id="toc-entry-54">Customizing Your Site</a></p></li>
  154. <li><p><a class="reference internal" href="handbook.html#fancy-dates" id="toc-entry-55">Fancy Dates</a></p></li>
  155. <li><p><a class="reference internal" href="handbook.html#adding-files" id="toc-entry-56">Adding Files</a></p></li>
  156. <li><p><a class="reference internal" href="handbook.html#custom-themes" id="toc-entry-57">Custom Themes</a></p></li>
  157. <li><p><a class="reference internal" href="handbook.html#getting-extra-themes" id="toc-entry-58">Getting Extra Themes</a></p></li>
  158. <li>
  159. <p><a class="reference internal" href="handbook.html#deployment" id="toc-entry-59">Deployment</a></p>
  160. <ul>
  161. <li><p><a class="reference internal" href="handbook.html#deploying-to-github" id="toc-entry-60">Deploying to GitHub</a></p></li>
  162. <li><p><a class="reference internal" href="handbook.html#automated-rebuilds-github-actions-gitlab" id="toc-entry-61">Automated rebuilds (GitHub Actions, GitLab)</a></p></li>
  163. </ul>
  164. </li>
  165. <li><p><a class="reference internal" href="handbook.html#comments" id="toc-entry-62">Comments</a></p></li>
  166. <li>
  167. <p><a class="reference internal" href="handbook.html#images-and-galleries" id="toc-entry-63">Images and Galleries</a></p>
  168. <ul>
  169. <li><p><a class="reference internal" href="handbook.html#embedding-images" id="toc-entry-64">Embedding Images</a></p></li>
  170. </ul>
  171. </li>
  172. <li>
  173. <p><a class="reference internal" href="handbook.html#handling-exif-data" id="toc-entry-65">Handling EXIF Data</a></p>
  174. <ul>
  175. <li><p><a class="reference internal" href="handbook.html#strip-all-exif-data" id="toc-entry-66">Strip all EXIF data</a></p></li>
  176. <li><p><a class="reference internal" href="handbook.html#preserve-all-exif-data" id="toc-entry-67">Preserve all EXIF data</a></p></li>
  177. <li><p><a class="reference internal" href="handbook.html#preserve-some-exif-data" id="toc-entry-68">Preserve some EXIF data</a></p></li>
  178. </ul>
  179. </li>
  180. <li><p><a class="reference internal" href="handbook.html#handling-icc-profiles" id="toc-entry-69">Handling ICC Profiles</a></p></li>
  181. <li><p><a class="reference internal" href="handbook.html#post-processing-filters" id="toc-entry-70">Post Processing Filters</a></p></li>
  182. <li><p><a class="reference internal" href="handbook.html#optimizing-your-website" id="toc-entry-71">Optimizing Your Website</a></p></li>
  183. <li>
  184. <p><a class="reference internal" href="handbook.html#math" id="toc-entry-72">Math</a></p>
  185. <ul>
  186. <li><p><a class="reference internal" href="handbook.html#configuration-1" id="toc-entry-73">Configuration</a></p></li>
  187. <li><p><a class="reference internal" href="handbook.html#inline-usage" id="toc-entry-74">Inline usage</a></p></li>
  188. <li><p><a class="reference internal" href="handbook.html#display-usage" id="toc-entry-75">Display usage</a></p></li>
  189. </ul>
  190. </li>
  191. <li>
  192. <p><a class="reference internal" href="handbook.html#restructuredtext-extensions" id="toc-entry-76">reStructuredText Extensions</a></p>
  193. <ul>
  194. <li><p><a class="reference internal" href="handbook.html#includes" id="toc-entry-77">Includes</a></p></li>
  195. <li><p><a class="reference internal" href="handbook.html#media" id="toc-entry-78">Media</a></p></li>
  196. <li><p><a class="reference internal" href="handbook.html#youtube" id="toc-entry-79">YouTube</a></p></li>
  197. <li><p><a class="reference internal" href="handbook.html#vimeo" id="toc-entry-80">Vimeo</a></p></li>
  198. <li><p><a class="reference internal" href="handbook.html#soundcloud" id="toc-entry-81">Soundcloud</a></p></li>
  199. <li><p><a class="reference internal" href="handbook.html#code" id="toc-entry-82">Code</a></p></li>
  200. <li><p><a class="reference internal" href="handbook.html#listing" id="toc-entry-83">Listing</a></p></li>
  201. <li><p><a class="reference internal" href="handbook.html#gist" id="toc-entry-84">Gist</a></p></li>
  202. <li><p><a class="reference internal" href="handbook.html#thumbnails" id="toc-entry-85">Thumbnails</a></p></li>
  203. <li><p><a class="reference internal" href="handbook.html#chart" id="toc-entry-86">Chart</a></p></li>
  204. <li><p><a class="reference internal" href="handbook.html#doc" id="toc-entry-87">Doc</a></p></li>
  205. <li><p><a class="reference internal" href="handbook.html#post-list" id="toc-entry-88">Post List</a></p></li>
  206. </ul>
  207. </li>
  208. <li>
  209. <p><a class="reference internal" href="handbook.html#importing-your-wordpress-site-into-nikola" id="toc-entry-89">Importing your WordPress site into Nikola</a></p>
  210. <ul>
  211. <li><p><a class="reference internal" href="handbook.html#importing-to-a-custom-location-or-into-an-existing-site" id="toc-entry-90">Importing to a custom location or into an existing site</a></p></li>
  212. </ul>
  213. </li>
  214. <li><p><a class="reference internal" href="handbook.html#using-twitter-cards" id="toc-entry-91">Using Twitter Cards</a></p></li>
  215. <li><p><a class="reference internal" href="handbook.html#custom-plugins" id="toc-entry-92">Custom Plugins</a></p></li>
  216. <li><p><a class="reference internal" href="handbook.html#getting-extra-plugins" id="toc-entry-93">Getting Extra Plugins</a></p></li>
  217. <li>
  218. <p><a class="reference internal" href="handbook.html#advanced-features" id="toc-entry-94">Advanced Features</a></p>
  219. <ul>
  220. <li><p><a class="reference internal" href="handbook.html#debugging" id="toc-entry-95">Debugging</a></p></li>
  221. <li><p><a class="reference internal" href="handbook.html#shell-tab-completion" id="toc-entry-96">Shell Tab Completion</a></p></li>
  222. </ul>
  223. </li>
  224. <li><p><a class="reference internal" href="handbook.html#license" id="toc-entry-97">License</a></p></li>
  225. </ul></nav><section id="all-you-need-to-know"><h2><a class="toc-backref" href="handbook.html#toc-entry-1" role="doc-backlink">All You Need to Know</a></h2>
  226. <p>After you have Nikola <a class="reference external" href="https://getnikola.com/getting-started.html">installed</a>:</p>
  227. <dl>
  228. <dt>Create an empty site (with a setup wizard):</dt>
  229. <dd>
  230. <p><code class="docutils literal">nikola init mysite</code></p>
  231. <p>You can create a site with demo files in it with <code class="docutils literal">nikola init <span class="pre">--demo</span> mysite</code></p>
  232. <p>The rest of these commands have to be executed inside the new <code class="docutils literal">mysite</code> folder.</p>
  233. </dd>
  234. <dt>Create a post:</dt>
  235. <dd>
  236. <p><code class="docutils literal">nikola new_post</code></p>
  237. </dd>
  238. <dt>Edit the post:</dt>
  239. <dd>
  240. <p>The filename should be in the output of the previous command.
  241. You can also use <code class="docutils literal">nikola new_post <span class="pre">-e</span></code> to open an editor automatically.</p>
  242. </dd>
  243. <dt>Build the site:</dt>
  244. <dd>
  245. <p><code class="docutils literal">nikola build</code></p>
  246. </dd>
  247. <dt>Start the test server and open a browser:</dt>
  248. <dd>
  249. <p><code class="docutils literal">nikola serve <span class="pre">-b</span></code></p>
  250. </dd>
  251. </dl>
  252. <p>That should get you going. If you want to know more, this manual will always be here
  253. for you.</p>
  254. <p>DON'T READ THIS MANUAL. IF YOU NEED TO READ IT I FAILED, JUST USE THE THING.</p>
  255. <p>On the other hand, if anything about Nikola is not as obvious as it should be, by all
  256. means tell me about it :-)</p>
  257. </section><section id="what-s-nikola-and-what-can-you-do-with-it"><h2><a class="toc-backref" href="handbook.html#toc-entry-2" role="doc-backlink">What's Nikola and what can you do with it?</a></h2>
  258. <p>Nikola is a static website and blog generator. The very short explanation is
  259. that it takes some texts you wrote, and uses them to create a folder full
  260. of HTML files. If you upload that folder to a server, you will have a
  261. rather full-featured website, done with little effort.</p>
  262. <p>Its original goal is to create blogs, but it supports most kind of sites, and
  263. can be used as a CMS, as long as what you present to the user is your own content
  264. instead of something the user generates.</p>
  265. <p>Nikola can do:</p>
  266. <ul class="simple">
  267. <li><p>A blog (<a class="reference external" href="https://ralsina.me">example</a>)</p></li>
  268. <li><p>Your company's site</p></li>
  269. <li><p>Your personal site</p></li>
  270. <li><p>A software project's site (<a class="reference external" href="https://getnikola.com">example</a>)</p></li>
  271. <li><p>A book's site</p></li>
  272. </ul>
  273. <p>Since Nikola-based sites don't run any code on the server, there is no way to process
  274. user input in forms.</p>
  275. <p>Nikola can't do:</p>
  276. <ul class="simple">
  277. <li><p>Twitter</p></li>
  278. <li><p>Facebook</p></li>
  279. <li><p>An Issue tracker</p></li>
  280. <li><p>Anything with forms, really (except for <a class="reference internal" href="handbook.html#comments">comments</a>!)</p></li>
  281. </ul>
  282. <p>Keep in mind that "static" doesn't mean <strong>boring</strong>. You can have animations
  283. or whatever fancy CSS3/HTML5 thingie you like. It only means all that HTML is
  284. generated already before being uploaded. On the other hand, Nikola sites will
  285. tend to be content-heavy. What Nikola is good at is at putting what you write
  286. out there.</p>
  287. </section><section id="getting-help"><h2><a class="toc-backref" href="handbook.html#toc-entry-3" role="doc-backlink">Getting Help</a></h2>
  288. <p class="lead"><a class="reference external" href="https://getnikola.com/contact.html">Get help here!</a></p>
  289. <p>TL;DR:</p>
  290. <ul class="simple">
  291. <li><p>You can file bugs at <a class="reference external" href="https://github.com/getnikola/nikola/issues">the issue tracker</a></p></li>
  292. <li><p>You can discuss Nikola at the <a class="reference external" href="https://groups.google.com/group/nikola-discuss">nikola-discuss google group</a></p></li>
  293. <li><p>You can subscribe to <a class="reference external" href="https://getnikola.com/blog">the Nikola Blog</a></p></li>
  294. <li><p>You can follow <a class="reference external" href="https://twitter.com/GetNikola">Nikola on Twitter</a></p></li>
  295. </ul></section><section id="why-static"><h2><a class="toc-backref" href="handbook.html#toc-entry-4" role="doc-backlink">Why Static?</a></h2>
  296. <p>Most "modern" websites are <em>dynamic</em> in the sense that the contents of the site
  297. live in a database, and are converted into presentation-ready HTML only when a
  298. user wants to see the page. That's great. However, it presents some minor issues
  299. that static site generators try to solve.</p>
  300. <p>In a static site, the whole site, every page, <em>everything</em>, is created before
  301. the first user even sees it and uploaded to the server as a simple folder full
  302. of HTML files (and images, CSS, etc).</p>
  303. <p>So, let's see some reasons for using static sites:</p>
  304. <dl>
  305. <dt>Security</dt>
  306. <dd>
  307. <p>Dynamic sites are prone to experience security issues. The solution for that
  308. is constant vigilance, keeping the software behind the site updated, and
  309. plain old good luck. The stack of software used to provide a static site,
  310. like those Nikola generates, is much smaller (Just a web server).</p>
  311. <p>A smaller software stack implies less security risk.</p>
  312. </dd>
  313. <dt>Obsolescence</dt>
  314. <dd>
  315. <p>If you create a site using (for example) WordPress, what happens when WordPress
  316. releases a new version? You have to update your WordPress. That is not optional,
  317. because of security and support issues. If I release a new version of Nikola, and
  318. you don't update, <em>nothing</em> happens. You can continue to use the version you
  319. have now forever, no problems.</p>
  320. <p>Also, in the longer term, the very foundations of dynamic sites shift. Can you
  321. still deploy a blog software based on Django 0.96? What happens when your
  322. host stops supporting the PHP version you rely on? And so on.</p>
  323. <p>You may say those are long term issues, or that they won't matter for years. Well,
  324. I believe things should work forever, or as close to it as we can make them.
  325. Nikola's static output and its input files will work as long as you can install
  326. Python 3.7 or newer under Linux, Windows, or macOS and can find a server
  327. that sends files over HTTP. That's probably 10 or 15 years at least.</p>
  328. <p>Also, static sites are easily handled by the Internet Archive.</p>
  329. </dd>
  330. <dt>Cost and Performance</dt>
  331. <dd>
  332. <p>On dynamic sites, every time a reader wants a page, a whole lot of database
  333. queries are made. Then a whole pile of code chews that data, and HTML is
  334. produced, which is sent to the user. All that requires CPU and memory.</p>
  335. <p>On a static site, the highly optimized HTTP server reads the file from disk
  336. (or, if it's a popular file, from disk cache), and sends it to the user. You could
  337. probably serve a bazillion (technical term) page views from a phone using
  338. static sites.</p>
  339. </dd>
  340. <dt>Lock-in</dt>
  341. <dd>
  342. <p>On server-side blog platforms, sometimes you can't export your own data, or
  343. it's in strange formats you can't use in other services. I have switched
  344. blogging platforms from Advogato to PyCs to two homebrew systems, to Nikola,
  345. and have never lost a file, a URL, or a comment. That's because I have <em>always</em>
  346. had my own data in a format of my choice.</p>
  347. <p>With Nikola, you own your files, and you can do anything with them.</p>
  348. </dd>
  349. </dl></section><section id="components"><h2><a class="toc-backref" href="handbook.html#toc-entry-5" role="doc-backlink">Components</a></h2>
  350. <p>Nikola provides the following features:</p>
  351. <ul class="simple">
  352. <li>
  353. <p>Blog support, including:</p>
  354. <ul>
  355. <li><p>Indexes</p></li>
  356. <li><p>RSS and Atom feeds</p></li>
  357. <li><p>Tags and categories, with pages and feeds</p></li>
  358. <li><p>Author pages and feeds (not generated if <code class="docutils literal">ENABLE_AUTHOR_PAGES</code> is set to <code class="docutils literal">False</code> or there is only one author)</p></li>
  359. <li><p>Archives with custom granularity (yearly or monthly)</p></li>
  360. <li><p><a class="reference internal" href="handbook.html#comments">Comments</a></p></li>
  361. </ul>
  362. </li>
  363. <li><p>Static pages (not part of the blog)</p></li>
  364. <li><p><a class="reference internal" href="handbook.html#math">Math</a> rendering (via MathJax)</p></li>
  365. <li><p>Custom output paths for generated pages</p></li>
  366. <li><p>Pretty URLs (without <code class="docutils literal">.html</code>) that don’t need web server support</p></li>
  367. <li><p>Easy page template customization</p></li>
  368. <li><p>Internationalization support (my own blog is English and Spanish)</p></li>
  369. <li><p>Sitemap generation (for search engines)</p></li>
  370. <li><p>Custom deployment (if it’s a command, you can use it)</p></li>
  371. <li><p>GitHub Pages deployment</p></li>
  372. <li><p>Themes, easy appearance customization</p></li>
  373. <li><p><a class="reference external" href="handbook.html#supported-input-formats">Multiple input formats</a>, including reStructuredText and Markdown</p></li>
  374. <li><p>Easy-to-create image galleries</p></li>
  375. <li><p>Image thumbnail generation</p></li>
  376. <li><p>Support for displaying source code listings</p></li>
  377. <li><p>Custom search</p></li>
  378. <li><p>Asset (CSS/JS) bundling</p></li>
  379. <li><p>gzip compression (for sending via your web server)</p></li>
  380. <li><p>Open Graph, Twitter Cards</p></li>
  381. <li><p>Hyphenation</p></li>
  382. <li><p>Custom <a class="reference internal" href="handbook.html#post-processing-filters">post processing filters</a> (eg. for minifying files or better typography)</p></li>
  383. </ul></section><section id="getting-started"><h2><a class="toc-backref" href="handbook.html#toc-entry-6" role="doc-backlink">Getting Started</a></h2>
  384. <p class="lead">To set Nikola up and create your first site, read the <a class="reference external" href="https://getnikola.com/getting-started.html">Getting Started Guide</a>.</p>
  385. </section><section id="creating-a-blog-post"><h2><a class="toc-backref" href="handbook.html#toc-entry-7" role="doc-backlink">Creating a Blog Post</a></h2>
  386. <aside class="sidebar"><p class="sidebar-title">Magic Links</p>
  387. <p>You will want to do things like "link from one post to another" or "link to an image gallery",
  388. etc. Sure, you can just figure out the URLs for each thing and use that. Or you can use
  389. Nikola's special link URLs. Those are done using the syntax <code class="docutils literal"><span class="pre">link://kind/name</span></code> and
  390. a full list of the included ones is <a class="reference external" href="path-handlers.html">here</a> (BTW, I linked
  391. to that using <code class="docutils literal"><span class="pre">link://slug/path-handlers</span></code>).</p>
  392. <p>Note that magic links with spaces won’t work with some input formats (eg.
  393. reST), so you should use slugs there (eg. <code class="docutils literal"><span class="pre">link://tag/some-tag</span></code> instead of
  394. <code class="docutils literal"><span class="pre">link://tag/Some</span> Tag</code>)</p>
  395. </aside><p>To create a new post, the easiest way is to run <code class="docutils literal">nikola new_post</code>. You will
  396. be asked for a title for your post, and it will tell you where the post's file
  397. is located.</p>
  398. <p>By default, that file will contain also some extra information about your post ("the metadata").
  399. It can be placed in a separate file by using the <code class="docutils literal"><span class="pre">-2</span></code> option, but it's generally
  400. easier to keep it in a single location.</p>
  401. <p>The contents of your post have to be written (by default) in <a class="reference external" href="https://docutils.sourceforge.io/">reStructuredText</a>
  402. but you can use a lot of different markups using the <code class="docutils literal"><span class="pre">-f</span></code> option.</p>
  403. <p>Currently, Nikola supports reStructuredText, Markdown, Jupyter Notebooks, HTML as input,
  404. can also use Pandoc for conversion, and has support for BBCode, CreoleWiki, txt2tags, Textile
  405. and more via plugins — for more details, read the <a class="reference external" href="handbook.html#multiple-input-formats">input format documentation</a>.
  406. You can learn reStructuredText syntax with the <a class="reference external" href="https://getnikola.com/quickstart.html">reST quickstart</a>.</p>
  407. <p>Please note that Nikola does not support encodings other than UTF-8. Make sure
  408. to convert your input files to that encoding to avoid issues. It will prevent
  409. bugs, and Nikola will write UTF-8 output anyway.</p>
  410. <p>You can control what markup compiler is used for each file extension with the <code class="docutils literal">COMPILERS</code>
  411. option. The default configuration expects them to be placed in <code class="docutils literal">posts</code> but that can be
  412. changed (see below, the <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code> options)</p>
  413. <p>This is how it works:</p>
  414. <pre class="code console"><a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-1"></a><span class="gp">$</span> nikola new_post
  415. <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-2"></a><span class="go">Creating New Post</span>
  416. <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-3"></a><span class="go">-----------------</span>
  417. <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-4"></a>
  418. <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-5"></a><span class="go">Title: How to make money</span>
  419. <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-6"></a><span class="go">Scanning posts....done!</span>
  420. <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-7"></a><span class="go">INFO: new_post: Your post's text is at: posts/how-to-make-money.rst</span>
  421. </pre>
  422. <p>The content of that file is as follows:</p>
  423. <pre class="code restructuredtext"><a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-1"></a><span class="cp">.. title: How to make money</span>
  424. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-2"></a><span class="cp">.. slug: how-to-make-money</span>
  425. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-3"></a><span class="cp">.. date: 2012-09-15 19:52:05 UTC</span>
  426. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-4"></a><span class="cp">.. tags:</span>
  427. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-5"></a><span class="cp">.. link:</span>
  428. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-6"></a><span class="cp">.. description:</span>
  429. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-7"></a><span class="cp">.. type: text</span>
  430. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-8"></a>
  431. <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-9"></a>Write your post here.
  432. </pre>
  433. <p>You can edit these files with your favorite text editor, and once you are happy
  434. with the contents, generate the pages using <code class="docutils literal">nikola build</code>.</p>
  435. <p>The post page is generated by default using the <code class="docutils literal">post.tmpl</code> template, which you can use
  436. to customize the output. You can also customize paths and the template filename
  437. itself — see <cite>How does Nikola decide where posts should go?</cite></p>
  438. <section id="metadata-fields"><h3><a class="toc-backref" href="handbook.html#toc-entry-8" role="doc-backlink">Metadata fields</a></h3>
  439. <p>Nikola supports many metadata fields in posts. All of them are
  440. translatable and almost all are optional.</p>
  441. <section id="basic"><h4><a class="toc-backref" href="handbook.html#toc-entry-9" role="doc-backlink">Basic</a></h4>
  442. <dl>
  443. <dt>title</dt>
  444. <dd>
  445. <p>Title of the post. Using HTML/math in titles is not supported/recommended.
  446. If not specified, the file name will be used.</p>
  447. </dd>
  448. <dt>slug</dt>
  449. <dd>
  450. <p>Slug of the post. Used as the last component of the page URL. We recommend
  451. and default to using a restricted character set (<code class="docutils literal"><span class="pre">a-z0-9-_</span></code>) because
  452. other symbols may cause issues in URLs. If not specified, the file name will be used.</p>
  453. <p>So, if the slug is "the-slug" the page generated would be "the-slug.html" or
  454. "the-slug/index.html" (if you have the pretty URLs option enabled)</p>
  455. <p>One special case is setting the slug to "index". This means the page generated
  456. would be "some_folder/index.html", which means it will be open for the URL
  457. that ends in "some_folder" or "some_folder/".</p>
  458. <p>This is useful in some cases, in others may cause conflicts with other pages
  459. Nikola generates (like blog indexes) and as a side effect it disables
  460. "pretty URLs" for this page. So use with care.</p>
  461. </dd>
  462. <dt>date</dt>
  463. <dd>
  464. <p>Date of the post, defaults to now. Multiple date formats are accepted.
  465. Adding a timezone is recommended. (required for posts)</p>
  466. </dd>
  467. <dt>tags</dt>
  468. <dd>
  469. <p>Comma-separated tags of the post.</p>
  470. </dd>
  471. <dt>status</dt>
  472. <dd>
  473. <p>Can be set to <code class="docutils literal">published</code> (default), <code class="docutils literal">featured</code>, <code class="docutils literal">draft</code>, or <code class="docutils literal">private</code>.</p>
  474. </dd>
  475. <dt>has_math</dt>
  476. <dd>
  477. <p>If set to <code class="docutils literal">true</code> or <code class="docutils literal">yes</code>, MathJax resp. KaTeX support is enabled
  478. for this post.</p>
  479. </dd>
  480. <dt>category</dt>
  481. <dd>
  482. <p>Like tags, except each post can have only one, and they usually have
  483. more descriptive names.</p>
  484. </dd>
  485. <dt>guid</dt>
  486. <dd>
  487. <p>String used as GUID in RSS feeds and as ID in Atom feeds instead of the
  488. permalink.</p>
  489. </dd>
  490. <dt>link</dt>
  491. <dd>
  492. <p>Link to original source for content. May be displayed by some themes.</p>
  493. </dd>
  494. <dt>description</dt>
  495. <dd>
  496. <p>Description of the post. Used in <code class="docutils literal">&lt;meta&gt;</code> tags for SEO.</p>
  497. </dd>
  498. <dt>type</dt>
  499. <dd>
  500. <p>Type of the post. See <a class="reference internal" href="handbook.html#post-types">Post Types</a> for details. Whatever you set here
  501. (prepended with <code class="docutils literal">post-</code>) will become a CSS class of the <code class="docutils literal">&lt;article&gt;</code>
  502. element for this post. Defaults to <code class="docutils literal">text</code> (resulting in a <code class="docutils literal"><span class="pre">post-text</span></code>
  503. class)</p>
  504. </dd>
  505. </dl></section><section id="extra"><h4><a class="toc-backref" href="handbook.html#toc-entry-10" role="doc-backlink">Extra</a></h4>
  506. <dl>
  507. <dt>author</dt>
  508. <dd>
  509. <p>Author of the post, will be used in the RSS feed and possibly in the post
  510. display (theme-dependent)</p>
  511. </dd>
  512. <dt>enclosure</dt>
  513. <dd>
  514. <p>Add an enclosure to this post when it's used in RSS. See <a class="reference external" href="https://en.wikipedia.org/wiki/RSS_enclosure">more information about enclosures</a></p>
  515. </dd>
  516. <dt>data</dt>
  517. <dd>
  518. <p>Path to an external data file (JSON/YAML/TOML dictionary), relative to <code class="docutils literal">conf.py</code>.
  519. Its keys are available for templates as <code class="docutils literal"><span class="pre">post.data('key')</span></code>.</p>
  520. <p>Translated posts can have different values for this field, and the correct one will be
  521. used.</p>
  522. <p>See <a class="reference internal" href="handbook.html#the-global-context-and-data-files">The Global Context and Data files</a> for more details. This is
  523. especially useful used in combination with <a class="reference internal" href="handbook.html#shortcodes">shortcodes</a>.</p>
  524. </dd>
  525. <dt>filters</dt>
  526. <dd>
  527. <p>See the <a class="reference internal" href="handbook.html#post-processing-filters">Post Processing Filters</a> section.</p>
  528. </dd>
  529. <dt>hidetitle</dt>
  530. <dd>
  531. <p>Set "True" if you do not want to see the <strong>page</strong> title as a
  532. heading of the output html file (does not work for posts).</p>
  533. </dd>
  534. <dt>hyphenate</dt>
  535. <dd>
  536. <p>Set "True" if you want this document to be hyphenated even if you have
  537. hyphenation disabled by default.</p>
  538. </dd>
  539. <dt>nocomments</dt>
  540. <dd>
  541. <p>Set to "True" to disable comments.</p>
  542. </dd>
  543. <dt>pretty_url</dt>
  544. <dd>
  545. <p>Set to "False" to disable pretty URL for this page.</p>
  546. </dd>
  547. <dt>previewimage</dt>
  548. <dd>
  549. <p>Designate a preview or other representative image path relative to BASE_URL
  550. for use with Open Graph for posts. Adds the image when sharing on social
  551. media, feeds, and many other uses.</p>
  552. <pre class="code restructuredtext"><a name="rest_code_97a673e5affa4cf4b57957e3e858b667-1"></a><span class="cp">.. previewimage: /images/looks_great_on_facebook.png</span>
  553. </pre>
  554. <p>If a post has no <cite>previewimage</cite> it will try to use the <cite>DEFAULT_PREVIEW_IMAGE</cite>
  555. option from the configuration.</p>
  556. <p>The image can be of any size and dimension (services will crop and adapt)
  557. but should less than 1 MB and be larger than 300x300 (ideally 600x600).</p>
  558. <p>This image is displayed by <code class="docutils literal">bootblog4</code> for featured posts (see <a class="reference internal" href="handbook.html#featured-posts">Featured
  559. Posts</a> for details).</p>
  560. </dd>
  561. <dt>template</dt>
  562. <dd>
  563. <p>Change the template used to render this page/post specific page. That
  564. template needs to either be part of the theme, or be placed in a
  565. <code class="docutils literal">templates/</code> folder inside your site.</p>
  566. <pre class="code restructuredtext"><a name="rest_code_b80b58639b8041c3924a6ca547364653-1"></a><span class="cp">.. template: foobar.tmpl</span>
  567. </pre>
  568. </dd>
  569. <dt>updated</dt>
  570. <dd>
  571. <p>The last time this post was updated, defaults to the post’s <code class="docutils literal">date</code>
  572. metadata value. It is not displayed by default in most themes, including
  573. the defaults — you can use <code class="docutils literal">post.formatted_updated(date_format)</code> (and
  574. perhaps check <code class="docutils literal">if post.updated != post.date</code>) in your post template to
  575. show it.</p>
  576. </dd>
  577. </dl>
  578. <p>To add these metadata fields to all new posts by default, you can set the
  579. variable <code class="docutils literal">ADDITIONAL_METADATA</code> in your configuration. For example, you can
  580. add the author metadata to all new posts by default, by adding the following
  581. to your configuration:</p>
  582. <pre class="code python"><a name="rest_code_50d82e8fa05a410d9742622ce1b51a2f-1"></a><span class="n">ADDITIONAL_METADATA</span> <span class="o">=</span> <span class="p">{</span>
  583. <a name="rest_code_50d82e8fa05a410d9742622ce1b51a2f-2"></a> <span class="s1">'author'</span><span class="p">:</span> <span class="s1">'John Doe'</span>
  584. <a name="rest_code_50d82e8fa05a410d9742622ce1b51a2f-3"></a><span class="p">}</span>
  585. </pre>
  586. <dl>
  587. <dt>url_type</dt>
  588. <dd>
  589. <p>Change the URL_TYPE setting for the given page only. Useful for eg. error
  590. pages which cannot use relative URLs.</p>
  591. <pre class="code restructuredtext"><a name="rest_code_2854eb3509c24c4bbe597eaaacef8728-1"></a><span class="cp">.. url_type: full_path</span>
  592. </pre>
  593. </dd>
  594. </dl></section></section><section id="metadata-formats"><h3><a class="toc-backref" href="handbook.html#toc-entry-11" role="doc-backlink">Metadata formats</a></h3>
  595. <p>Metadata can be in different formats.
  596. Current Nikola versions experimentally supports other metadata formats that make it more compatible with
  597. other static site generators. The currently supported metadata formats are:</p>
  598. <ul class="simple">
  599. <li><p>reST-style comments (<code class="docutils literal">.. name: value</code> — default format)</p></li>
  600. <li><p>Two-file format (reST-style, YAML, TOML)</p></li>
  601. <li><p>Jupyter Notebook metadata</p></li>
  602. <li><p>YAML, between <code class="docutils literal"><span class="pre">---</span></code> (Jekyll, Hugo)</p></li>
  603. <li><p>TOML, between <code class="docutils literal">+++</code> (Hugo)</p></li>
  604. <li><p>reST docinfo (Pelican)</p></li>
  605. <li><p>Markdown metadata extension (Pelican)</p></li>
  606. <li><p>HTML meta tags (Pelican)</p></li>
  607. </ul>
  608. <p>You can add arbitrary meta fields in any format.</p>
  609. <p>When you create new posts, by default the metadata will be created as reST style comments.
  610. If you prefer a different format, you can set the <code class="docutils literal">METADATA_FORMAT</code> to one of these values:</p>
  611. <ul class="simple">
  612. <li><p><code class="docutils literal">"Nikola"</code>: reST comments, wrapped in a HTML comment if needed (default)</p></li>
  613. <li><p><code class="docutils literal">"YAML"</code>: YAML wrapped in "---"</p></li>
  614. <li><p><code class="docutils literal">"TOML"</code>: TOML wrapped in "+++"</p></li>
  615. <li><p><code class="docutils literal">"Pelican"</code>: Native markdown metadata or reST docinfo fields. Nikola style for other formats.</p></li>
  616. </ul>
  617. <section id="rest-style-comments"><h4><a class="toc-backref" href="handbook.html#toc-entry-12" role="doc-backlink">reST-style comments</a></h4>
  618. <p>The “traditional” and default meta field format is:</p>
  619. <pre class="code text"><a name="rest_code_f90ce434a9874e66ba5689c7d1bab7ad-1"></a>.. name: value
  620. </pre>
  621. <p>If you are not using reStructuredText, make sure the fields are in a HTML comment in output.</p>
  622. <p>Also, note that this format does not support any multi-line values. Try YAML or reST docinfo if you need those.</p>
  623. </section><section id="two-file-format"><h4><a class="toc-backref" href="handbook.html#toc-entry-13" role="doc-backlink">Two-file format</a></h4>
  624. <p>Meta information can also be specified in separate <code class="docutils literal">.meta</code> files. Those support reST-style metadata, with names and custom fields. They look like the beginning of our reST files:</p>
  625. <pre class="code text"><a name="rest_code_1022c20cc60e4916ba5a84038643797e-1"></a>.. title: How to make money
  626. <a name="rest_code_1022c20cc60e4916ba5a84038643797e-2"></a>.. slug: how-to-make-money
  627. <a name="rest_code_1022c20cc60e4916ba5a84038643797e-3"></a>.. date: 2012-09-15 19:52:05 UTC
  628. </pre>
  629. <p>You can also use YAML or TOML metadata inside those (with the appropriate markers).</p>
  630. </section><section id="jupyter-notebook-metadata"><h4><a class="toc-backref" href="handbook.html#toc-entry-14" role="doc-backlink">Jupyter Notebook metadata</a></h4>
  631. <p>Jupyter posts can store meta information inside <code class="docutils literal">.ipynb</code> files by using the <code class="docutils literal">nikola</code> key inside notebook metadata. It can be edited by using <em>Edit → Edit Notebook Metadata</em> in Jupyter. Note that values are currently only strings. Sample metadata (Jupyter-specific information omitted):</p>
  632. <pre class="code json"><a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-1"></a><span class="p">{</span>
  633. <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-2"></a> <span class="nt">"nikola"</span><span class="p">:</span> <span class="p">{</span>
  634. <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-3"></a> <span class="nt">"title"</span><span class="p">:</span> <span class="s2">"How to make money"</span><span class="p">,</span>
  635. <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-4"></a> <span class="nt">"slug"</span><span class="p">:</span> <span class="s2">"how-to-make-money"</span><span class="p">,</span>
  636. <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-5"></a> <span class="nt">"date"</span><span class="p">:</span> <span class="s2">"2012-09-15 19:52:05 UTC"</span>
  637. <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-6"></a> <span class="p">}</span>
  638. <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-7"></a><span class="p">}</span>
  639. </pre></section><section id="yaml-metadata"><h4><a class="toc-backref" href="handbook.html#toc-entry-15" role="doc-backlink">YAML metadata</a></h4>
  640. <p>YAML metadata should be wrapped by a <code class="docutils literal"><span class="pre">---</span></code> separator (three dashes) and in that case, the usual YAML syntax is used:</p>
  641. <pre class="code yaml"><a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-1"></a><span class="nn">---</span>
  642. <a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-2"></a><span class="nt">title</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">How to make money</span>
  643. <a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-3"></a><span class="nt">slug</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">how-to-make-money</span>
  644. <a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-4"></a><span class="nt">date</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">2012-09-15 19:52:05 UTC</span>
  645. <a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-5"></a><span class="nn">---</span>
  646. </pre></section><section id="toml-metadata"><h4><a class="toc-backref" href="handbook.html#toc-entry-16" role="doc-backlink">TOML metadata</a></h4>
  647. <p>TOML metadata should be wrapped by a "+++" separator (three plus signs) and in that case, the usual TOML syntax is used:</p>
  648. <pre class="code yaml"><a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-1"></a><span class="l l-Scalar l-Scalar-Plain">+++</span>
  649. <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-2"></a><span class="l l-Scalar l-Scalar-Plain">title = "How to make money"</span>
  650. <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-3"></a><span class="l l-Scalar l-Scalar-Plain">slug = "how-to-make-money"</span>
  651. <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-4"></a><span class="l l-Scalar l-Scalar-Plain">date = "2012-09-15 19:52:05 UTC"</span>
  652. <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-5"></a><span class="l l-Scalar l-Scalar-Plain">+++</span>
  653. </pre></section><section id="rest-docinfo"><h4><a class="toc-backref" href="handbook.html#toc-entry-17" role="doc-backlink">reST docinfo</a></h4>
  654. <p>Nikola can extract metadata from reStructuredText docinfo fields and the document itself, too:</p>
  655. <pre class="code restructuredtext"><a name="rest_code_adc136ef3f8e4caf9316c947f102584d-1"></a><span class="gh">How to make money</span>
  656. <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-2"></a><span class="gh">=================</span>
  657. <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-3"></a>
  658. <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-4"></a><span class="nc">:slug:</span> how-to-make-money
  659. <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-5"></a><span class="nc">:date:</span> 2012-09-15 19:52:05 UTC
  660. </pre>
  661. <p>To do this, you need <code class="docutils literal">USE_REST_DOCINFO_METADATA = True</code> in your <code class="docutils literal">conf.py</code>,
  662. and Nikola will hide the docinfo fields in the output if you set
  663. <code class="docutils literal">HIDE_REST_DOCINFO = True</code>.</p>
  664. <aside class="admonition note"><p class="admonition-title">Note</p>
  665. <p>Keys are converted to lowercase automatically.</p>
  666. <p>This setting also means that the first heading in a post will be removed
  667. and considered a title. This is important if you’re mixing metadata
  668. styles. This can be solved by putting a reST comment before your title.</p>
  669. </aside></section><section id="pelican-markdown-metadata"><h4><a class="toc-backref" href="handbook.html#toc-entry-18" role="doc-backlink">Pelican/Markdown metadata</a></h4>
  670. <p>Markdown Metadata (Pelican-style) only works in Markdown files, and requires the <code class="docutils literal">markdown.extensions.meta</code> extension
  671. (see <a class="reference external" href="handbook.html#markdown">MARKDOWN_EXTENSIONS</a>). The exact format is described in
  672. the <a class="reference external" href="https://python-markdown.github.io/extensions/meta_data/">markdown metadata extension docs.</a></p>
  673. <pre class="code text"><a name="rest_code_7439c987f2344616a3b2cbb1a6cebfa9-1"></a>title: How to make money
  674. <a name="rest_code_7439c987f2344616a3b2cbb1a6cebfa9-2"></a>slug: how-to-make-money
  675. <a name="rest_code_7439c987f2344616a3b2cbb1a6cebfa9-3"></a>date: 2012-09-15 19:52:05 UTC
  676. </pre>
  677. <p>Note that keys are converted to lowercase automatically.</p>
  678. </section><section id="html-meta-tags"><h4><a class="toc-backref" href="handbook.html#toc-entry-19" role="doc-backlink">HTML meta tags</a></h4>
  679. <p>For HTML source files, metadata will be extracted from <code class="docutils literal">meta</code> tags, and the title from the <code class="docutils literal">title</code> tag.
  680. Following Pelican's behaviour, tags can be put in a "tags" meta tag or in a "keywords" meta tag. Example:</p>
  681. <pre class="code html"><a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-1"></a><span class="p">&lt;</span><span class="nt">html</span><span class="p">&gt;</span>
  682. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-2"></a> <span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span>
  683. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-3"></a> <span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span>My super title<span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
  684. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-4"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"tags"</span> <span class="na">content</span><span class="o">=</span><span class="s">"thats, awesome"</span> <span class="p">/&gt;</span>
  685. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-5"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"date"</span> <span class="na">content</span><span class="o">=</span><span class="s">"2012-07-09 22:28"</span> <span class="p">/&gt;</span>
  686. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-6"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"modified"</span> <span class="na">content</span><span class="o">=</span><span class="s">"2012-07-10 20:14"</span> <span class="p">/&gt;</span>
  687. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-7"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"category"</span> <span class="na">content</span><span class="o">=</span><span class="s">"yeah"</span> <span class="p">/&gt;</span>
  688. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-8"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"authors"</span> <span class="na">content</span><span class="o">=</span><span class="s">"Conan Doyle"</span> <span class="p">/&gt;</span>
  689. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-9"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"summary"</span> <span class="na">content</span><span class="o">=</span><span class="s">"Short version for index and feeds"</span> <span class="p">/&gt;</span>
  690. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-10"></a> <span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  691. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-11"></a> <span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>
  692. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-12"></a> This is the content of my super blog post.
  693. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-13"></a> <span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
  694. <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-14"></a><span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
  695. </pre></section><section id="mapping-metadata-from-other-formats"><h4><a class="toc-backref" href="handbook.html#toc-entry-20" role="doc-backlink">Mapping metadata from other formats</a></h4>
  696. <p>If you import posts from other engines, those may not work with Nikola out of the box due to differing names. However, you can create a mapping to convert meta field names from those formats into what Nikola expects.</p>
  697. <p>For Pelican, use:</p>
  698. <pre class="code python"><a name="rest_code_e726dc97319445be881e170a226ccf89-1"></a><span class="n">METADATA_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
  699. <a name="rest_code_e726dc97319445be881e170a226ccf89-2"></a> <span class="s2">"rest_docinfo"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"summary"</span><span class="p">:</span> <span class="s2">"description"</span><span class="p">,</span> <span class="s2">"modified"</span><span class="p">:</span> <span class="s2">"updated"</span><span class="p">},</span>
  700. <a name="rest_code_e726dc97319445be881e170a226ccf89-3"></a> <span class="s2">"markdown_metadata"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"summary"</span><span class="p">:</span> <span class="s2">"description"</span><span class="p">,</span> <span class="s2">"modified"</span><span class="p">:</span> <span class="s2">"updated"</span><span class="p">}</span>
  701. <a name="rest_code_e726dc97319445be881e170a226ccf89-4"></a> <span class="s2">"html_metadata"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"summary"</span><span class="p">:</span> <span class="s2">"description"</span><span class="p">,</span> <span class="s2">"modified"</span><span class="p">:</span> <span class="s2">"updated"</span><span class="p">}</span>
  702. <a name="rest_code_e726dc97319445be881e170a226ccf89-5"></a><span class="p">}</span>
  703. </pre>
  704. <p>For Hugo, use:</p>
  705. <pre class="code python"><a name="rest_code_fd7d31032d31435784f80d60617c05a5-1"></a><span class="n">METADATA_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
  706. <a name="rest_code_fd7d31032d31435784f80d60617c05a5-2"></a> <span class="s2">"yaml"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"lastmod"</span><span class="p">:</span> <span class="s2">"updated"</span><span class="p">},</span>
  707. <a name="rest_code_fd7d31032d31435784f80d60617c05a5-3"></a> <span class="s2">"toml"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"lastmod"</span><span class="p">:</span> <span class="s2">"updated"</span><span class="p">}</span>
  708. <a name="rest_code_fd7d31032d31435784f80d60617c05a5-4"></a><span class="p">}</span>
  709. </pre>
  710. <p>The following source names are supported: <code class="docutils literal">yaml</code>, <code class="docutils literal">toml</code>, <code class="docutils literal">rest_docinfo</code>, <code class="docutils literal">markdown_metadata</code>.</p>
  711. <p>Additionally, you can use <code class="docutils literal">METADATA_VALUE_MAPPING</code> to perform any extra conversions on metadata for <strong>all</strong> posts of a given format (<code class="docutils literal">nikola</code> metadata is also supported). A few examples:</p>
  712. <pre class="code python"><a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-1"></a><span class="n">METADATA_VALUE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
  713. <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-2"></a> <span class="s2">"yaml"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"keywords"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">value</span><span class="p">:</span> <span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">value</span><span class="p">)},</span> <span class="c1"># yaml: 'keywords' list -&gt; str</span>
  714. <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-3"></a> <span class="s2">"nikola"</span><span class="p">:</span> <span class="p">{</span>
  715. <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-4"></a> <span class="s2">"widgets"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">value</span><span class="p">:</span> <span class="n">value</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">', '</span><span class="p">),</span> <span class="c1"># nikola: 'widgets' comma-separated string -&gt; list</span>
  716. <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-5"></a> <span class="s2">"tags"</span><span class="p">:</span> <span class="nb">str</span><span class="o">.</span><span class="n">lower</span> <span class="c1"># nikola: force lowercase 'tags' (input would be string)</span>
  717. <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-6"></a> <span class="p">}</span>
  718. <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-7"></a><span class="p">}</span>
  719. </pre></section></section><section id="multilingual-posts"><h3><a class="toc-backref" href="handbook.html#toc-entry-21" role="doc-backlink">Multilingual posts</a></h3>
  720. <p>If you are writing a multilingual site, you can also create a per-language
  721. post file (for example: <code class="docutils literal"><span class="pre">how-to-make-money.es.txt</span></code> with the default TRANSLATIONS_PATTERN, see below).
  722. This one can replace metadata of the default language, for example:</p>
  723. <ul class="simple">
  724. <li><p>The translated title for the post or page</p></li>
  725. <li><p>A translated version of the page name</p></li>
  726. </ul>
  727. <p>The pattern used for finding translations is controlled by the
  728. TRANSLATIONS_PATTERN variable in your configuration file.</p>
  729. <p>The default is to put the language code before the file extension,
  730. so the German translation of <code class="docutils literal">some_file.rst</code> should be named
  731. <code class="docutils literal">some_file.de.rst</code>. This is because the TRANSLATIONS_PATTERN variable is by
  732. default set to:</p>
  733. <pre class="code python"><a name="rest_code_9628a225d3d54553b5c855dc79ca360f-1"></a><span class="n">TRANSLATIONS_PATTERN</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{path}</span><span class="s2">.</span><span class="si">{lang}</span><span class="s2">.</span><span class="si">{ext}</span><span class="s2">"</span>
  734. </pre>
  735. <aside class="admonition admonition-considered-languages"><p class="admonition-title">Considered languages</p>
  736. <p>Nikola will only look for translation of input files for languages
  737. specified in the TRANSLATIONS variable.</p>
  738. </aside><p>In case you translate your posts, you might also want to adjust various
  739. other settings so that the generated URLs match the translation. You can
  740. find most places in <code class="docutils literal">conf.py</code> by searching for <code class="docutils literal">(translatable)</code>. For example,
  741. you might want to localize <code class="docutils literal">/categories/</code> (search for <code class="docutils literal">TAG_PATH</code>), <code class="docutils literal">/pages/</code>
  742. and <code class="docutils literal">/posts/</code> (search for <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code>, or see the next section), or
  743. how to adjust the URLs for subsequent pages for indexes (search for
  744. <code class="docutils literal">INDEXES_PRETTY_PAGE_URL</code>).</p>
  745. <p>Nikola supports multiple languages for a post (we have almost 50 translations!). If you wish to
  746. add support for more languages, check out <a class="reference external" href="https://www.transifex.com/projects/p/nikola/">the Transifex page for Nikola</a>.</p>
  747. </section><section id="how-does-nikola-decide-where-posts-should-go"><h3><a class="toc-backref" href="handbook.html#toc-entry-22" role="doc-backlink">How does Nikola decide where posts should go?</a></h3>
  748. <p>The place where the post will be placed by <code class="docutils literal">new_post</code> (the first one that
  749. matches the given format) and the final post destination (the first one that
  750. matches a given file) is based on the <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code> configuration
  751. options. The exact mechanism is explained above the config options in the
  752. <code class="docutils literal">conf.py</code> file, and also reproduced below:</p>
  753. <pre class="code python"><a name="rest_code_6843e34d56cb46c7baae4db401bbab10-1"></a><span class="c1"># POSTS and PAGES contains (wildcard, destination, template) tuples.</span>
  754. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-2"></a><span class="c1">#</span>
  755. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-3"></a><span class="c1"># The wildcard is used to generate a list of post source files</span>
  756. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-4"></a><span class="c1"># (whatever/thing.rst, for example).</span>
  757. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-5"></a><span class="c1">#</span>
  758. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-6"></a><span class="c1"># That fragment could have an associated metadata file (whatever/thing.meta),</span>
  759. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-7"></a><span class="c1"># and optionally translated files (example for Spanish, with code "es"):</span>
  760. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-8"></a><span class="c1"># whatever/thing.es.rst and whatever/thing.es.meta</span>
  761. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-9"></a><span class="c1">#</span>
  762. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-10"></a><span class="c1"># This assumes you use the default TRANSLATIONS_PATTERN.</span>
  763. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-11"></a><span class="c1">#</span>
  764. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-12"></a><span class="c1"># From those files, a set of HTML fragment files will be generated:</span>
  765. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-13"></a><span class="c1"># cache/whatever/thing.html (and maybe cache/whatever/thing.html.es)</span>
  766. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-14"></a><span class="c1">#</span>
  767. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-15"></a><span class="c1"># These files are combined with the template to produce rendered</span>
  768. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-16"></a><span class="c1"># pages, which will be placed at</span>
  769. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-17"></a><span class="c1"># output/TRANSLATIONS[lang]/destination/pagename.html</span>
  770. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-18"></a><span class="c1">#</span>
  771. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-19"></a><span class="c1"># where "pagename" is the "slug" specified in the metadata file.</span>
  772. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-20"></a><span class="c1"># The page might also be placed in /destination/pagename/index.html</span>
  773. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-21"></a><span class="c1"># if PRETTY_URLS are enabled.</span>
  774. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-22"></a><span class="c1">#</span>
  775. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-23"></a><span class="c1"># The difference between POSTS and PAGES is that POSTS are added</span>
  776. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-24"></a><span class="c1"># to feeds, indexes, tag lists and archives and are considered part</span>
  777. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-25"></a><span class="c1"># of a blog, while PAGES are just independent HTML pages.</span>
  778. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-26"></a><span class="c1">#</span>
  779. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-27"></a><span class="c1"># Finally, note that destination can be translated, i.e. you can</span>
  780. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-28"></a><span class="c1"># specify a different translation folder per language. Example:</span>
  781. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-29"></a><span class="c1"># PAGES = (</span>
  782. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-30"></a><span class="c1"># ("pages/*.rst", {"en": "pages", "de": "seiten"}, "page.tmpl"),</span>
  783. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-31"></a><span class="c1"># ("pages/*.md", {"en": "pages", "de": "seiten"}, "page.tmpl"),</span>
  784. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-32"></a><span class="c1"># )</span>
  785. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-33"></a>
  786. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-34"></a><span class="n">POSTS</span> <span class="o">=</span> <span class="p">(</span>
  787. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-35"></a> <span class="p">(</span><span class="s2">"posts/*.rst"</span><span class="p">,</span> <span class="s2">"posts"</span><span class="p">,</span> <span class="s2">"post.tmpl"</span><span class="p">),</span>
  788. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-36"></a> <span class="p">(</span><span class="s2">"posts/*.txt"</span><span class="p">,</span> <span class="s2">"posts"</span><span class="p">,</span> <span class="s2">"post.tmpl"</span><span class="p">),</span>
  789. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-37"></a> <span class="p">(</span><span class="s2">"posts/*.html"</span><span class="p">,</span> <span class="s2">"posts"</span><span class="p">,</span> <span class="s2">"post.tmpl"</span><span class="p">),</span>
  790. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-38"></a><span class="p">)</span>
  791. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-39"></a><span class="n">PAGES</span> <span class="o">=</span> <span class="p">(</span>
  792. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-40"></a> <span class="p">(</span><span class="s2">"pages/*.rst"</span><span class="p">,</span> <span class="s2">"pages"</span><span class="p">,</span> <span class="s2">"page.tmpl"</span><span class="p">),</span>
  793. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-41"></a> <span class="p">(</span><span class="s2">"pages/*.txt"</span><span class="p">,</span> <span class="s2">"pages"</span><span class="p">,</span> <span class="s2">"page.tmpl"</span><span class="p">),</span>
  794. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-42"></a> <span class="p">(</span><span class="s2">"pages/*.html"</span><span class="p">,</span> <span class="s2">"pages"</span><span class="p">,</span> <span class="s2">"page.tmpl"</span><span class="p">),</span>
  795. <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-43"></a><span class="p">)</span>
  796. </pre>
  797. <aside class="admonition admonition-posts-and-pages-are-not-flat"><p class="admonition-title">POSTS and PAGES are not flat!</p>
  798. <p>Even if the syntax may suggest you can't, you can create any directory structure you want
  799. inside <code class="docutils literal">posts/</code> or <code class="docutils literal">pages/</code> and it will be reflected in the output. For example,
  800. <code class="docutils literal">posts/foo/bar.txt</code> would produce <code class="docutils literal">output/posts/foo/bar.html</code>, assuming the slug is also <code class="docutils literal">bar</code>.</p>
  801. <p>If you have <code class="docutils literal">PRETTY_URLS</code> enabled, that would be <code class="docutils literal">output/posts/foo/bar/index.html</code>.</p>
  802. </aside><aside class="admonition warning"><p class="admonition-title">Warning</p>
  803. <p>Removing the <code class="docutils literal">.rst</code> entries is not recommended. Some features (eg.
  804. shortcodes) may not work properly if you do that.</p>
  805. </aside></section><section id="the-new-post-command"><h3><a class="toc-backref" href="handbook.html#toc-entry-23" role="doc-backlink">The <code class="docutils literal">new_post</code> command</a></h3>
  806. <p><code class="docutils literal">new_post</code> will use the <em>first</em> path in <code class="docutils literal">POSTS</code> (or <code class="docutils literal">PAGES</code> if <code class="docutils literal"><span class="pre">-p</span></code> is
  807. supplied) that ends with the extension of your desired markup format (as
  808. defined in <code class="docutils literal">COMPILERS</code> in <code class="docutils literal">conf.py</code>) as the directory that the new post will be
  809. written into. If no such entry can be found, the post won’t be created.</p>
  810. <p>The <code class="docutils literal">new_post</code> command supports some options:</p>
  811. <pre class="code text"><a name="rest_code_9782f0650e3444fd9faf1a32898ca329-1"></a>$ nikola help new_post
  812. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-2"></a>Purpose: create a new blog post or site page
  813. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-3"></a>Usage: nikola new_post [options] [path]
  814. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-4"></a>
  815. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-5"></a>Options:
  816. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-6"></a> -p, --page Create a page instead of a blog post. (see also: `nikola new_page`)
  817. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-7"></a> -t ARG, --title=ARG Title for the post.
  818. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-8"></a> -a ARG, --author=ARG Author of the post.
  819. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-9"></a> --tags=ARG Comma-separated tags for the post.
  820. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-10"></a> -1 Create the post with embedded metadata (single file format)
  821. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-11"></a> -2 Create the post with separate metadata (two file format)
  822. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-12"></a> -e Open the post (and meta file, if any) in $EDITOR after creation.
  823. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-13"></a> -f ARG, --format=ARG Markup format for the post (use --available-formats for list)
  824. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-14"></a> -F, --available-formats List all available input formats
  825. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-15"></a> -s Schedule the post based on recurrence rule
  826. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-16"></a> -i ARG, --import=ARG Import an existing file instead of creating a placeholder
  827. <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-17"></a> -d, --date-path Create post with date path (eg. year/month/day, see NEW_POST_DATE_PATH_FORMAT in config)
  828. </pre>
  829. <p>The optional <code class="docutils literal">path</code> parameter tells Nikola exactly where to put it instead of guessing from your config.
  830. So, if you do <code class="docutils literal">nikola new_post posts/random/foo.txt</code> you will have a post in that path, with
  831. "foo" as its slug. You can also provide a directory name, in which case Nikola
  832. will append the file name for you (generated from title).</p>
  833. <p>The <code class="docutils literal"><span class="pre">-d,</span> <span class="pre">--date-path</span></code> option automates creation of <code class="docutils literal">year/month/day</code> or
  834. similar directory structures. It can be enabled on a per-post basis, or you can
  835. use it for every post if you set <code class="docutils literal">NEW_POST_DATE_PATH = True</code> in conf.py.</p>
  836. <pre class="code python"><a name="rest_code_c080bce44b294cb3be1a350c765176a7-1"></a><span class="c1"># Use date-based path when creating posts?</span>
  837. <a name="rest_code_c080bce44b294cb3be1a350c765176a7-2"></a><span class="c1"># Can be enabled on a per-post basis with `nikola new_post -d`.</span>
  838. <a name="rest_code_c080bce44b294cb3be1a350c765176a7-3"></a><span class="c1"># NEW_POST_DATE_PATH = False</span>
  839. <a name="rest_code_c080bce44b294cb3be1a350c765176a7-4"></a>
  840. <a name="rest_code_c080bce44b294cb3be1a350c765176a7-5"></a><span class="c1"># What format to use when creating posts with date paths?</span>
  841. <a name="rest_code_c080bce44b294cb3be1a350c765176a7-6"></a><span class="c1"># Default is '%Y/%m/%d', other possibilities include '%Y' or '%Y/%m'.</span>
  842. <a name="rest_code_c080bce44b294cb3be1a350c765176a7-7"></a><span class="c1"># NEW_POST_DATE_PATH_FORMAT = '%Y/%m/%d'</span>
  843. </pre></section><section id="teasers"><h3><a class="toc-backref" href="handbook.html#toc-entry-24" role="doc-backlink">Teasers</a></h3>
  844. <p>You may not want to show the complete content of your posts either on your
  845. index page or in RSS feeds, but to display instead only the beginning of them.</p>
  846. <p>If it's the case, you only need to add a "magical comment" <code class="docutils literal">TEASER_END</code> or
  847. <code class="docutils literal">END_TEASER</code> in your post.</p>
  848. <p>In reStructuredText:</p>
  849. <pre class="code restructuredtext"><a name="rest_code_796ffc3896b74430bde6bfbf2cbc40db-1"></a><span class="cp">.. TEASER_END</span>
  850. </pre>
  851. <p>In Markdown (or basically, the resulting HTML of any format):</p>
  852. <pre class="code html"><a name="rest_code_788bd8bb39c1481f81629f603ec19247-1"></a><span class="c">&lt;!-- TEASER_END --&gt;</span>
  853. </pre>
  854. <p>By default all your RSS feeds will be shortened (they'll contain only teasers)
  855. whereas your index page will still show complete posts. You can change
  856. this behavior with your <code class="docutils literal">conf.py</code>: <code class="docutils literal">INDEX_TEASERS</code> defines whether index
  857. page should display the whole contents or only teasers. <code class="docutils literal">FEED_TEASERS</code>
  858. works the same way for your Atom and RSS feeds.</p>
  859. <p>By default, teasers will include a "read more" link at the end. If you want to
  860. change that text, you can use a custom teaser:</p>
  861. <pre class="code restructuredtext"><a name="rest_code_02756d18a9d140a7810d348b18f65273-1"></a><span class="cp">.. TEASER_END: click to read the rest of the article</span>
  862. </pre>
  863. <p>You can override the default value for <code class="docutils literal">TEASER_END</code> in <code class="docutils literal">conf.py</code> — for
  864. example, the following example will work for <code class="docutils literal">.. more</code>, and will be
  865. compatible with both WordPress and Nikola posts:</p>
  866. <pre class="code python"><a name="rest_code_4169f76ff18044958b6007a3e59afadc-1"></a><span class="kn">import</span> <span class="nn">re</span>
  867. <a name="rest_code_4169f76ff18044958b6007a3e59afadc-2"></a><span class="n">TEASER_REGEXP</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s1">'&lt;!--\s*(more|TEASER_END|END_TEASER)(:(.+))?\s*--&gt;'</span><span class="p">,</span> <span class="n">re</span><span class="o">.</span><span class="n">IGNORECASE</span><span class="p">)</span>
  868. </pre>
  869. <p>Or you can completely customize the link using the <code class="docutils literal">READ_MORE_LINK</code> option.</p>
  870. <pre class="code python"><a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-1"></a><span class="c1"># A HTML fragment with the Read more... link.</span>
  871. <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-2"></a><span class="c1"># The following tags exist and are replaced for you:</span>
  872. <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-3"></a><span class="c1"># {link} A link to the full post page.</span>
  873. <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-4"></a><span class="c1"># {read_more} The string “Read more” in the current language.</span>
  874. <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-5"></a><span class="c1"># {{ A literal { (U+007B LEFT CURLY BRACKET)</span>
  875. <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-6"></a><span class="c1"># }} A literal } (U+007D RIGHT CURLY BRACKET)</span>
  876. <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-7"></a><span class="c1"># READ_MORE_LINK = '&lt;p class="more"&gt;&lt;a href="{link}"&gt;{read_more}…&lt;/a&gt;&lt;/p&gt;'</span>
  877. </pre></section><section id="drafts"><h3><a class="toc-backref" href="handbook.html#toc-entry-25" role="doc-backlink">Drafts</a></h3>
  878. <p>If you set the <code class="docutils literal">status</code> metadata field of a post to <code class="docutils literal">draft</code>, it will not be shown
  879. in indexes and feeds. It <em>will</em> be compiled, and if you deploy it it <em>will</em> be made
  880. available, so use with care. If you wish your drafts to be not available in your
  881. deployed site, you can set <code class="docutils literal">DEPLOY_DRAFTS = False</code> in your configuration. This will
  882. not work if you include <code class="docutils literal">nikola build</code> in your <code class="docutils literal">DEPLOY_COMMANDS</code>, as the
  883. option removes the draft posts before any <code class="docutils literal">DEPLOY_COMMANDS</code> are run.</p>
  884. <p>Also if a post has a date in the future, it will not be shown in indexes until
  885. you rebuild after that date. This behavior can be disabled by setting
  886. <code class="docutils literal">FUTURE_IS_NOW = True</code> in your configuration, which will make future posts be
  887. published immediately. Posts dated in the future are <em>not</em> deployed by default
  888. (when <code class="docutils literal">FUTURE_IS_NOW = False</code>). To make future posts available in the
  889. deployed site, you can set <code class="docutils literal">DEPLOY_FUTURE = True</code> in your configuration.
  890. Generally, you want FUTURE_IS_NOW and DEPLOY_FUTURE to be the same value.</p>
  891. </section><section id="private-posts"><h3><a class="toc-backref" href="handbook.html#toc-entry-26" role="doc-backlink">Private Posts</a></h3>
  892. <p>If you set the <code class="docutils literal">status</code> metadata field of a post to <code class="docutils literal">private</code>, it will not be shown
  893. in indexes and feeds. It <em>will</em> be compiled, and if you deploy it it <em>will</em> be made
  894. available, so it will not generate 404s for people who had linked to it.</p>
  895. </section><section id="featured-posts"><h3><a class="toc-backref" href="handbook.html#toc-entry-27" role="doc-backlink">Featured Posts</a></h3>
  896. <p>Some themes, <code class="docutils literal">bootblog4</code> in particular, support featured posts. To mark a
  897. post as featured, simply set the <code class="docutils literal">status</code> meta field to <code class="docutils literal">featured</code>. All
  898. featured posts are available in index templates in a <code class="docutils literal">featured</code>
  899. list, but only if this is the main blog index.</p>
  900. <p>For bootblog4, you can display up to three posts as featured: one can be shown
  901. in a large gray box (jumbotron), and two more can appear in small white
  902. cards. In order to enable this feature, you need to add <code class="docutils literal">THEME_CONFIG</code> to
  903. your configuration, and set it up properly:</p>
  904. <pre class="code python"><a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-1"></a><span class="n">THEME_CONFIG</span> <span class="o">=</span> <span class="p">{</span>
  905. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-2"></a> <span class="n">DEFAULT_LANG</span><span class="p">:</span> <span class="p">{</span>
  906. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-3"></a> <span class="c1"># Show the latest featured post in a large box, with the previewimage as its background.</span>
  907. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-4"></a> <span class="s1">'featured_large'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
  908. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-5"></a> <span class="c1"># Show the first (remaining) two featured posts in small boxes.</span>
  909. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-6"></a> <span class="s1">'featured_small'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
  910. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-7"></a> <span class="c1"># Show featured posts on mobile.</span>
  911. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-8"></a> <span class="s1">'featured_on_mobile'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
  912. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-9"></a> <span class="c1"># Show image in `featured_large` on mobile.</span>
  913. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-10"></a> <span class="c1"># `featured_small` displays them only on desktop.</span>
  914. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-11"></a> <span class="s1">'featured_large_image_on_mobile'</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
  915. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-12"></a> <span class="c1"># Strip HTML from featured post text.</span>
  916. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-13"></a> <span class="s1">'featured_strip_html'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
  917. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-14"></a> <span class="c1"># Contents of the sidebar, If empty, the sidebar is not displayed.</span>
  918. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-15"></a> <span class="s1">'sidebar'</span><span class="p">:</span> <span class="s1">''</span>
  919. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-16"></a> <span class="p">}</span>
  920. <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-17"></a><span class="p">}</span>
  921. </pre>
  922. <p>You can pick betweeen (up to) 1, 2, or 3 featured posts. You can mix
  923. <code class="docutils literal">featured_large</code> and <code class="docutils literal">featured_small</code>, rest assured that Nikola will always
  924. display the latest posts no matter what setup you choose. If only one posts
  925. qualifies for the small cards, one card taking up all the width will appear.</p>
  926. <p>Both featured box formats display an image to the right. You can set it by changing the <code class="docutils literal">previewimage</code> meta value to the full path to the image (eg. <code class="docutils literal">.. previewimage: /images/featured1.png</code>). This works best with images in portrait orientation.</p>
  927. <p>Note that, due to space constraints, only the large box may show the image on
  928. mobile, below the text (this behavior can be disbled). Small boxes never
  929. display images on mobile. In particular: <code class="docutils literal">xs</code> and <code class="docutils literal">sm</code> display only the
  930. large image, and only if configured; <code class="docutils literal">md</code> displays only the large image,
  931. <code class="docutils literal">lg</code> displays all three images.</p>
  932. <p>The boxes display only the teaser. We recommend keeping it short so
  933. you don’t get an ugly scrollbar.</p>
  934. <p>Finally, here’s an example (you’ll need to imagine a scrollbar in the right box
  935. yourself):</p>
  936. <a class="reference external image-reference" href="https://getnikola.com/images/bootblog4-featured2x.png"><img alt="An example of how featured posts look in bootblog4." class="align-center" src="https://getnikola.com/images/bootblog4-featured2x.thumbnail.png"></a>
  937. </section><section id="queuing-posts"><h3><a class="toc-backref" href="handbook.html#toc-entry-28" role="doc-backlink">Queuing Posts</a></h3>
  938. <p>Some blogs tend to have new posts based on a schedule (for example,
  939. every Mon, Wed, Fri) but the blog authors don't like to manually
  940. schedule their posts. You can schedule your blog posts based on a
  941. rule, by specifying a rule in the <code class="docutils literal">SCHEDULE_RULE</code> in your
  942. configuration. You can either post specific blog posts according to
  943. this schedule by using the <code class="docutils literal"><span class="pre">--schedule</span></code> flag on the <code class="docutils literal">new_post</code>
  944. command or post all new posts according to this schedule by setting
  945. <code class="docutils literal">SCHEDULE_ALL = True</code> in your configuration. (Note: This feature
  946. requires that the <code class="docutils literal">FUTURE_IS_NOW</code> setting is set to <code class="docutils literal">False</code>)</p>
  947. <p>For example, if you would like to schedule your posts to be on every
  948. Monday, Wednesday and Friday at 7am, add the following
  949. <code class="docutils literal">SCHEDULE_RULE</code> to your configuration:</p>
  950. <pre class="code python"><a name="rest_code_e199bcced54a4aad92c8faac51a1834a-1"></a><span class="n">SCHEDULE_RULE</span> <span class="o">=</span> <span class="s1">'RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR;BYHOUR=7;BYMINUTE=0;BYSECOND=0'</span>
  951. </pre>
  952. <p>For more details on how to specify a recurrence rule, look at the
  953. <a class="reference external" href="https://www.kanzaki.com/docs/ical/rrule.html">iCal specification</a>.
  954. Or if you are scared of this format, many calendaring applications (eg. Google
  955. Calendar) offer iCal exports, so you can copy-paste the repeat rule from a
  956. generated iCal (<code class="docutils literal">.ics</code>) file (which is a human-readable text file).</p>
  957. <p>Say, you get a free Sunday, and want to write a flurry of new posts,
  958. or at least posts for the rest of the week, you would run the
  959. <code class="docutils literal">new_post</code> command with the <code class="docutils literal"><span class="pre">--schedule</span></code> flag, as many times as
  960. you want:</p>
  961. <pre class="code console"><a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-1"></a><span class="gp">$</span> nikola new_post --schedule
  962. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-2"></a><span class="gp">#</span> Creates a new post to be posted on Monday, 7am.
  963. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-3"></a><span class="gp">$</span> nikola new_post -s
  964. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-4"></a><span class="gp">#</span> Creates a new post to be posted on Wednesday, 7am.
  965. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-5"></a><span class="gp">$</span> nikola new_post -s
  966. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-6"></a><span class="gp">#</span> Creates a new post to be posted on Friday, 7am.
  967. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-7"></a><span class="go">.</span>
  968. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-8"></a><span class="go">.</span>
  969. <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-9"></a><span class="go">.</span>
  970. </pre>
  971. <p>All these posts get queued up according to your schedule, but note
  972. that you will anyway need to build and deploy your site for the posts
  973. to appear online. You can have a cron job that does this regularly.</p>
  974. </section><section id="post-types"><h3><a class="toc-backref" href="handbook.html#toc-entry-29" role="doc-backlink">Post Types</a></h3>
  975. <p>Nikola supports specifying post types, just like Tumblr does. Post
  976. types affect the look of your posts, by adding a <code class="docutils literal"><span class="pre">post-YOURINPUTHERE</span></code>
  977. CSS class to the post. Each post can have one and exactly one type. Nikola
  978. styles the following types in the default themes:</p>
  979. <table class="table table-bordered">
  980. <thead><tr>
  981. <th class="head"><p>Name(s)</p></th>
  982. <th class="head"><p>Description</p></th>
  983. <th class="head"><p>Styling</p></th>
  984. </tr></thead>
  985. <tbody>
  986. <tr>
  987. <td><p>text</p></td>
  988. <td><p>plain text — default value</p></td>
  989. <td><p>standard</p></td>
  990. </tr>
  991. <tr>
  992. <td><p>micro</p></td>
  993. <td><p>“small” (short) posts</p></td>
  994. <td><p>big serif font</p></td>
  995. </tr>
  996. </tbody>
  997. </table></section><section id="indexes"><h3><a class="toc-backref" href="handbook.html#toc-entry-30" role="doc-backlink">Indexes</a></h3>
  998. <p>All your posts that are not drafts, private or dated in the future, will be
  999. shown in indexes.</p>
  1000. <section id="settings"><h4><a class="toc-backref" href="handbook.html#toc-entry-31" role="doc-backlink">Settings</a></h4>
  1001. <p>Indexes are put in the <code class="docutils literal">INDEX_PATH</code> directory, which defaults to an empty
  1002. string (site root). The “main” index is <code class="docutils literal">index.html</code>, and all the further
  1003. indexes are <code class="docutils literal"><span class="pre">index-*.html</span></code>, respectively.</p>
  1004. <p>By default, 10 posts are displayed on an index page. This can be changed with
  1005. <code class="docutils literal">INDEX_DISPLAY_POST_COUNT</code>. Indexes can show full posts or just the teasers,
  1006. as controlled by the <code class="docutils literal">INDEX_TEASERS</code> setting (defaults to <code class="docutils literal">False</code>).</p>
  1007. <p>Titles of the pages can be controlled by using <code class="docutils literal">INDEXES_TITLES</code>,
  1008. <code class="docutils literal">INDEXES_PAGES</code> and <code class="docutils literal">INDEXES_PAGES_MAIN</code> settings.</p>
  1009. <p>Categories and tags use simple lists by default that show only titles and
  1010. dates; however, you can switch them to full indexes by using
  1011. <code class="docutils literal">CATEGORY_PAGES_ARE_INDEXES</code> and <code class="docutils literal">TAG_PAGES_ARE_INDEXES</code>, respectively.</p>
  1012. <p>Something similar happens with authors. To use full indexes in authors, set
  1013. <code class="docutils literal">AUTHOR_PAGES_ARE_INDEXES</code> to <code class="docutils literal">True</code>.</p>
  1014. </section><section id="static-indexes"><h4><a class="toc-backref" href="handbook.html#toc-entry-32" role="doc-backlink">Static indexes</a></h4>
  1015. <p>Nikola uses <em>static indexes</em> by default. This means that <code class="docutils literal"><span class="pre">index-1.html</span></code> has
  1016. the oldest posts, and the newest posts past the first 10 are in
  1017. <code class="docutils literal"><span class="pre">index-N.html</span></code>, where <code class="docutils literal">N</code> is the highest number. Only the page with the
  1018. highest number and the main page (<code class="docutils literal"><span class="pre">index-N.html</span></code> and <code class="docutils literal">index.html</code>) are
  1019. rebuilt (the others remain unchanged). The page that appears when you click
  1020. <em>Older posts</em> on the index page, <code class="docutils literal"><span class="pre">index-N.html</span></code>, might contain <strong>less than 10
  1021. posts</strong> if there are not enough posts to fill up all pages.</p>
  1022. <p>This can be disabled by setting <code class="docutils literal">INDEXES_STATIC</code> to <code class="docutils literal">False</code>. In that mode,
  1023. <code class="docutils literal"><span class="pre">index-1.html</span></code> contains all the newest posts past the first 10 and will
  1024. always contain 10 posts (unless you have less than 20). The last page,
  1025. <code class="docutils literal"><span class="pre">index-N.html</span></code>, contains the oldest posts, and might contain less than 10
  1026. posts. This is how many blog engines and CMSes behave. Note that this will
  1027. lead to rebuilding all index pages, which might be a problem for larger blogs
  1028. (with a lot of index pages).</p>
  1029. </section></section><section id="post-taxonomy"><h3><a class="toc-backref" href="handbook.html#toc-entry-33" role="doc-backlink">Post taxonomy</a></h3>
  1030. <p>There are two taxonomy systems in Nikola, or two ways to organize posts. Those are tags and categories. They are visible on the <em>Tags and Categories</em> page, by default available at <code class="docutils literal">/categories/</code>. Each tag/category has an index page and feeds.</p>
  1031. <section id="tags"><h4><a class="toc-backref" href="handbook.html#toc-entry-34" role="doc-backlink">Tags</a></h4>
  1032. <p>Tags are the smallest and most basic of the taxonomy items. A post can have multiple tags, specified using the <code class="docutils literal">tags</code> metadata entry (comma-separated). You should provide many tags to help your readers, and perhaps search engines, find content on your site.</p>
  1033. <p>Please note that tags are case-sensitive and that you cannot have two tags that differ only in case/punctuation (eg. using <code class="docutils literal">nikola</code> in one post and <code class="docutils literal">Nikola</code> in another will lead to a crash):</p>
  1034. <pre class="code text"><a name="rest_code_1fd858ac735b4e729c0d0c4ca1acda15-1"></a>ERROR: Nikola: You have tags that are too similar: Nikola and nikola
  1035. <a name="rest_code_1fd858ac735b4e729c0d0c4ca1acda15-2"></a>ERROR: Nikola: Tag Nikola is used in: posts/second-post.rst
  1036. <a name="rest_code_1fd858ac735b4e729c0d0c4ca1acda15-3"></a>ERROR: Nikola: Tag nikola is used in: posts/1.rst
  1037. </pre>
  1038. <p>You can also generate a tag cloud with the <a class="reference external" href="https://plugins.getnikola.com/v7/tx3_tag_cloud/">tx3_tag_cloud</a> plugin or get a data file for a tag cloud with the <a class="reference external" href="https://plugins.getnikola.com/v8/tagcloud/">tagcloud</a> plugin.</p>
  1039. </section><section id="categories"><h4><a class="toc-backref" href="handbook.html#toc-entry-35" role="doc-backlink">Categories</a></h4>
  1040. <p>The next unit for organizing your content are categories. A post can have only one category, specified with the <code class="docutils literal">category</code> meta tag. They are displayed alongside tags. You can have categories and tags with the same name (categories’ RSS and HTML files are prefixed with <code class="docutils literal">cat_</code> by default).</p>
  1041. <p>Categories are handy to organize different parts of your blog, parts that are about different topics. Unlike tags, which you should have tens (hundreds?) of, the list of categories should be shorter.</p>
  1042. <p>Nikola v7 used to support a third taxonomy, called sections. Those have been removed, but all the functionality can be recreated by using the <code class="docutils literal">CATEGORY_DESTPATH</code> settings.</p>
  1043. </section><section id="configuring-tags-and-categories"><h4><a class="toc-backref" href="handbook.html#toc-entry-36" role="doc-backlink">Configuring tags and categories</a></h4>
  1044. <p>There are multiple configuration variables dedicated to each of the two taxonomies. You can set:</p>
  1045. <ul class="simple">
  1046. <li><p><code class="docutils literal">TAG_PATH</code>, <code class="docutils literal">TAGS_INDEX_PATH</code>, <code class="docutils literal">CATEGORY_PATH</code>, <code class="docutils literal">CATEGORY_PREFIX</code> to configure paths used for tags and categories</p></li>
  1047. <li><p><code class="docutils literal">TAG_TITLES</code>, <code class="docutils literal">CATEGORY_TITLES</code> to set titles and descriptions for index pages</p></li>
  1048. <li><p><code class="docutils literal">TAG_DESCRIPTIONS</code>, <code class="docutils literal">CATEGORY_DESCRIPTIONS</code> to set descriptions for each of the items</p></li>
  1049. <li><p><code class="docutils literal">CATEGORY_ALLOW_HIERARCHIES</code> and <code class="docutils literal">CATEGORY_OUTPUT_FLAT_HIERARCHIES</code> to allow hierarchical categories</p></li>
  1050. <li><p><code class="docutils literal">TAG_PAGES_ARE_INDEXES</code> and <code class="docutils literal">CATEGORY_PAGES_ARE_INDEXES</code> to display full-size indexes instead of simple post lists</p></li>
  1051. <li><p><code class="docutils literal">HIDDEN_TAGS</code>. <code class="docutils literal">HIDDEN_CATEGORIES</code> to make some tags/categories invisible in lists</p></li>
  1052. <li><p><code class="docutils literal">CATEGORY_DESTPATH_AS_DEFAULT</code> to use the destination path as the category if none is specified in the post</p></li>
  1053. <li><p><code class="docutils literal">CATEGORY_DESTPATH_TRIM_PREFIX</code> to trim the prefix that comes from <code class="docutils literal">POSTS</code> for the destination path</p></li>
  1054. <li><p><code class="docutils literal">CATEGORY_DESTPATH_FIRST_DIRECTORY</code> to only use the first directory name for the defaulted category</p></li>
  1055. <li><p><code class="docutils literal">CATEGORY_DESTPATH_NAMES</code> to specify friendly names for defaulted categories</p></li>
  1056. <li><p><code class="docutils literal">CATEGORY_PAGES_FOLLOW_DESTPATH</code> to put category pages next to their related posts (via destpath)</p></li>
  1057. </ul></section></section><section id="what-if-i-dont-want-a-blog"><h3><a class="toc-backref" href="handbook.html#toc-entry-37" role="doc-backlink">What if I don’t want a blog?</a></h3>
  1058. <p>If you want a static site that does not have any blog-related elements, see our
  1059. <a class="reference external" href="https://getnikola.com/creating-a-site-not-a-blog-with-nikola.html">Creating a Site (Not a Blog) with Nikola</a> guide.</p>
  1060. </section></section><section id="creating-a-page"><h2><a class="toc-backref" href="handbook.html#toc-entry-38" role="doc-backlink">Creating a Page</a></h2>
  1061. <p>Pages are the same as posts, except that:</p>
  1062. <ul class="simple">
  1063. <li><p>They are not added to the front page</p></li>
  1064. <li><p>They don't appear on the RSS feed</p></li>
  1065. <li><p>They use the <code class="docutils literal">page.tmpl</code> template instead of <code class="docutils literal">post.tmpl</code> by default</p></li>
  1066. </ul>
  1067. <p>The default configuration expects the page's metadata and text files to be on the
  1068. <code class="docutils literal">pages</code> folder, but that can be changed (see <code class="docutils literal">PAGES</code> option above).</p>
  1069. <p>You can create the page's files manually or use the <code class="docutils literal">new_post</code> command
  1070. with the <code class="docutils literal"><span class="pre">-p</span></code> option, which will place the files in the folder that
  1071. has <code class="docutils literal">use_in_feed</code> set to False.</p>
  1072. <p>In some places (including default directories and templates), pages are called
  1073. <em>stories</em> for historic reasons. Both are synonyms for the same thing: pages
  1074. that are not blog posts.</p>
  1075. </section><section id="supported-input-formats"><h2><a class="toc-backref" href="handbook.html#toc-entry-39" role="doc-backlink">Supported input formats</a></h2>
  1076. <p>Nikola supports multiple input formats. Out of the box, we have compilers available for:</p>
  1077. <ul class="simple">
  1078. <li><p>reStructuredText (default and pre-configured)</p></li>
  1079. <li><p><a class="reference internal" href="handbook.html#markdown">Markdown</a> (pre-configured since v7.8.7)</p></li>
  1080. <li><p><a class="reference internal" href="handbook.html#jupyter-notebook">Jupyter Notebook</a></p></li>
  1081. <li><p><a class="reference internal" href="handbook.html#html">HTML</a></p></li>
  1082. <li><p><a class="reference internal" href="handbook.html#php">PHP</a></p></li>
  1083. <li><p>anything <a class="reference internal" href="handbook.html#pandoc">Pandoc</a> supports (including Textile, DocBook, LaTeX, MediaWiki,
  1084. TWiki, OPML, Emacs Org-Mode, txt2tags, Microsoft Word .docx, EPUB, Haddock markup)</p></li>
  1085. </ul>
  1086. <p>Plus, we have specialized compilers in the Plugins Index for:</p>
  1087. <ul class="simple">
  1088. <li><p><a class="reference external" href="https://plugins.getnikola.com/#asciidoc">AsciiDoc</a></p></li>
  1089. <li><p><a class="reference external" href="https://plugins.getnikola.com/#bbcode">BBCode</a></p></li>
  1090. <li><p><a class="reference external" href="https://plugins.getnikola.com/#commonmark">CommonMark</a></p></li>
  1091. <li><p><a class="reference external" href="https://plugins.getnikola.com/#irclogs">IRC logs</a></p></li>
  1092. <li><p><a class="reference external" href="https://plugins.getnikola.com/#markmin">Markmin</a></p></li>
  1093. <li><p><a class="reference external" href="https://plugins.getnikola.com/#mediawiki">MediaWiki (smc.mw)</a></p></li>
  1094. <li><p><a class="reference external" href="https://plugins.getnikola.com/#misaka">Misaka</a></p></li>
  1095. <li><p><a class="reference external" href="https://plugins.getnikola.com/#odt">ODT</a></p></li>
  1096. <li><p><a class="reference external" href="https://plugins.getnikola.com/#orgmode">Emacs Org-Mode</a></p></li>
  1097. <li><p><a class="reference external" href="https://plugins.getnikola.com/#rest_html5">reST with HTML 5 output</a></p></li>
  1098. <li><p><a class="reference external" href="https://plugins.getnikola.com/#textile">Textile</a></p></li>
  1099. <li><p><a class="reference external" href="https://plugins.getnikola.com/#txt2tags">txt2tags</a></p></li>
  1100. <li><p><a class="reference external" href="https://plugins.getnikola.com/#wiki">CreoleWiki</a></p></li>
  1101. <li><p><a class="reference external" href="https://plugins.getnikola.com/#wordpress_compiler">WordPress posts</a></p></li>
  1102. </ul>
  1103. <p>To write posts in a different format, you need to configure the compiler and
  1104. paths. To create a post, use <code class="docutils literal">nikola new_post <span class="pre">-f</span> COMPILER_NAME</code>, eg. <code class="docutils literal">nikola
  1105. new_post <span class="pre">-f</span> markdown</code>. The default compiler used is the first entry in POSTS
  1106. or PAGES.</p>
  1107. <section id="configuring-other-input-formats"><h3><a class="toc-backref" href="handbook.html#toc-entry-40" role="doc-backlink">Configuring other input formats</a></h3>
  1108. <p>In order to use input formats other than reStructuredText, you need some extra
  1109. setup.</p>
  1110. <ol class="arabic simple">
  1111. <li><p>Make sure you have the compiler for the input format you want. Some
  1112. input formats are supported out-of-the-box, but others must be installed from
  1113. the Plugins repository. You may also need some extra dependencies. You
  1114. will get helpful errors if you try to build when missing something.</p></li>
  1115. <li><p>You must ensure the compiler and your desired input file extension is included
  1116. in the <code class="docutils literal">COMPILERS</code> dict and does not conflict with any other format. This
  1117. is extremely important for the pandoc compiler.</p></li>
  1118. <li><p>Finally, you must configure the <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code> tuples. Follow the
  1119. instructions and the format set by pre-existing entries. Make sure to use
  1120. the same extension as is set in <code class="docutils literal">COMPILERS</code> and configure the outputs
  1121. properly.</p></li>
  1122. </ol>
  1123. <section id="markdown"><h4><a class="toc-backref" href="handbook.html#toc-entry-41" role="doc-backlink">Markdown</a></h4>
  1124. <p>To use Markdown in your posts/pages, make sure <code class="docutils literal">markdown</code> is in your
  1125. <code class="docutils literal">COMPILERS</code> and that at least one of your desired extensions is defined in
  1126. <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code>.</p>
  1127. <p>You can use Python-Markdown extensions by setting the <code class="docutils literal">MARKDOWN_EXTENSIONS</code>
  1128. config option:</p>
  1129. <pre class="code python"><a name="rest_code_a46ae67e54354434b5022a9db95d2952-1"></a><span class="n">MARKDOWN_EXTENSIONS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'fenced_code'</span><span class="p">,</span> <span class="s1">'codehilite'</span><span class="p">,</span> <span class="s1">'extra'</span><span class="p">]</span>
  1130. </pre>
  1131. <p>Nikola comes with some Markdown Extensions built-in and enabled by default,
  1132. namely a gist directive, a podcast directive, and <code class="docutils literal">~~strikethrough~~</code> support.</p>
  1133. </section><section id="jupyter-notebook"><h4><a class="toc-backref" href="handbook.html#toc-entry-42" role="doc-backlink">Jupyter Notebook</a></h4>
  1134. <p>To use Jupyter Notebooks as posts/pages, make sure <code class="docutils literal">ipynb</code> is in your
  1135. <code class="docutils literal">COMPILERS</code> and that the <code class="docutils literal">.ipynb</code> extension is defined in <code class="docutils literal">POSTS</code> and
  1136. <code class="docutils literal">PAGES</code>.</p>
  1137. <p>The <code class="docutils literal"><span class="pre">-f</span></code> argument to <code class="docutils literal">new_post</code> should be used in the <code class="docutils literal">ipynb@KERNEL</code> format.
  1138. It defaults to Python in the version used by Nikola if not specified.</p>
  1139. <p>Jupyter Notebooks are also supported in stand-alone listings, if Jupyter
  1140. support is enabled site-wide. You must have something for <code class="docutils literal">.ipynb</code> in POSTS
  1141. or PAGES for the feature to work.</p>
  1142. </section><section id="html"><h4><a class="toc-backref" href="handbook.html#toc-entry-43" role="doc-backlink">HTML</a></h4>
  1143. <p>To use plain HTML in your posts/pages, make sure <code class="docutils literal">html</code> is in your
  1144. <code class="docutils literal">COMPILERS</code>
  1145. and that the <code class="docutils literal">.html</code> extension is defined in <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code>.</p>
  1146. </section><section id="php"><h4><a class="toc-backref" href="handbook.html#toc-entry-44" role="doc-backlink">PHP</a></h4>
  1147. <p>There are two ways of using PHP within Nikola:</p>
  1148. <ol class="arabic simple">
  1149. <li><p>To use PHP in your posts/pages (inside your site, with the theme and
  1150. everything), make sure <code class="docutils literal">php</code> is in your <code class="docutils literal">COMPILERS</code> and that the <code class="docutils literal">.php</code>
  1151. extension is defined in <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code>.</p></li>
  1152. <li><p>To use PHP as standalone files (without any modifications), put them in
  1153. <code class="docutils literal">files/</code> (or whatever <code class="docutils literal">FILES_FOLDERS</code> is configured to).</p></li>
  1154. </ol></section><section id="pandoc"><h4><a class="toc-backref" href="handbook.html#toc-entry-45" role="doc-backlink">Pandoc</a></h4>
  1155. <p>To use Pandoc, you must uncomment the entry in <code class="docutils literal">COMPILERS</code> and set the
  1156. extensions list to your desired extensions while also removing them from their
  1157. original compilers. The input format is inferred from the extension by Pandoc.</p>
  1158. <p>Using Pandoc for reStructuredText, Markdown and other input formats that have a
  1159. standalone Nikola plugin is <strong>not recommended</strong> as it disables plugins and
  1160. extensions that are usually provided by Nikola.</p>
  1161. </section></section></section><section id="shortcodes"><h2><a class="toc-backref" href="handbook.html#toc-entry-46" role="doc-backlink">Shortcodes</a></h2>
  1162. <p>This feature is "inspired" (copied wholesale) from <a class="reference external" href="https://gohugo.io/extras/shortcodes/">Hugo</a> so I will
  1163. steal part of their docs too.</p>
  1164. <p>A shortcode is a simple snippet inside a content file that Nikola will render using a predefined template or
  1165. custom code from a plugin.</p>
  1166. <p>To use them from plugins, please see <a class="reference external" href="https://getnikola.com/extending.html#shortcodes">Extending Nikola</a></p>
  1167. <section id="using-a-shortcode"><h3><a class="toc-backref" href="handbook.html#toc-entry-47" role="doc-backlink">Using a shortcode</a></h3>
  1168. <p>In your content files, a shortcode can be called by using this form:</p>
  1169. <pre class="code text"><a name="rest_code_6b7397d9da374a2d89ab31d8b45b330f-1"></a>{{% name parameters %}}
  1170. </pre>
  1171. <p>Shortcode parameters are space delimited. Parameters with spaces can be quoted (or backslash escaped).</p>
  1172. <p>The first word is always the name of the shortcode. Parameters follow the name. Depending upon how the shortcode is defined, the parameters may be named, positional or both. The format for named parameters models that of HTML with the format name="value".</p>
  1173. <p>Some shortcodes use or require closing shortcodes. Like HTML, the opening and closing shortcodes match (name only), the closing being prepended with a slash.</p>
  1174. <p>Example of a paired shortcode (note that we don't have a highlight shortcode yet ;-):</p>
  1175. <pre class="code text"><a name="rest_code_1e131e5fc6034757a15f5771dcf2b942-1"></a>{{% highlight python %}} A bunch of code here {{% /highlight %}}
  1176. </pre>
  1177. <aside class="admonition admonition-shortcodes-and-restructuredtext"><p class="admonition-title">Shortcodes and reStructuredText</p>
  1178. <p>In reStructuredText shortcodes may fail because docutils turns URL into links and everything breaks.
  1179. For some shortcodes there are alternative docutils directives (example, you can use the media
  1180. <strong>directive</strong> instead of the media shortcode.</p>
  1181. <p>Also, you can use the shortcode <strong>role</strong>:</p>
  1182. <pre class="code text"><a name="rest_code_0cacd5f7c1074a69b8a05093efbf003a-1"></a>:sc:`{{% shortcode here %}}`
  1183. </pre>
  1184. <p>That role passes text unaltered, so shortcodes behave correctly.</p>
  1185. </aside></section><section id="built-in-shortcodes"><h3><a class="toc-backref" href="handbook.html#toc-entry-48" role="doc-backlink">Built-in shortcodes</a></h3>
  1186. <aside class="admonition warning"><p class="admonition-title">Warning</p>
  1187. <p>Some of the shortcodes are implemented as bindings to reST directives. In
  1188. order to use them, you need at least one entry for <code class="docutils literal">*.rst</code> in
  1189. POSTS/PAGES.</p>
  1190. </aside><dl>
  1191. <dt>chart</dt>
  1192. <dd>
  1193. <p>Create charts via PyGal. This is similar to the <a class="reference external" href="handbook.html#chart">chart directive</a> except the syntax is adapted to
  1194. shortcodes. This is an example:</p>
  1195. <pre class="code text"><a name="rest_code_9d84fdc1b4ed46b492a2126e3a2c60fc-1"></a>{{% chart Bar title='Browser usage evolution (in %)'
  1196. x_labels='["2002","2003","2004","2005","2006","2007"]' %}}
  1197. 'Firefox', [None, None, 0, 16.6, 25, 31]
  1198. 'Chrome', [None, None, None, None, None, None]
  1199. 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
  1200. 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
  1201. {{% /chart %}}
  1202. </pre>
  1203. <p>Additionally, you can use a file_data argument which can point to a JSON or YAML file, and will be used for both arguments and data.
  1204. Example:</p>
  1205. <pre class="code json"><a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-1"></a><span class="p">{</span>
  1206. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-2"></a> <span class="nt">"x_labels"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"2002"</span><span class="p">,</span><span class="s2">"2003"</span><span class="p">,</span><span class="s2">"2004"</span><span class="p">,</span><span class="s2">"2005"</span><span class="p">,</span><span class="s2">"2006"</span><span class="p">,</span><span class="s2">"2007"</span><span class="p">],</span>
  1207. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-3"></a> <span class="nt">"data"</span><span class="p">:</span> <span class="p">{</span>
  1208. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-4"></a> <span class="nt">"Firefox"</span><span class="p">:</span> <span class="p">[</span><span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">16.6</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="mi">31</span><span class="p">],</span>
  1209. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-5"></a> <span class="nt">"Chrome"</span><span class="p">:</span> <span class="p">[</span><span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">],</span>
  1210. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-6"></a> <span class="nt">"IE"</span><span class="p">:</span> <span class="p">[</span><span class="mf">85.8</span><span class="p">,</span> <span class="mf">84.6</span><span class="p">,</span> <span class="mf">84.7</span><span class="p">,</span> <span class="mf">74.5</span><span class="p">,</span> <span class="mi">66</span><span class="p">,</span> <span class="mf">58.6</span><span class="p">],</span>
  1211. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-7"></a> <span class="nt">"Others"</span><span class="p">:</span> <span class="p">[</span><span class="mf">14.2</span><span class="p">,</span> <span class="mf">15.4</span><span class="p">,</span> <span class="mf">15.3</span><span class="p">,</span> <span class="mf">8.9</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mf">10.4</span><span class="p">]</span>
  1212. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-8"></a> <span class="p">}</span>
  1213. <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-9"></a><span class="p">}</span>
  1214. </pre>
  1215. <p>Which can be used like this:</p>
  1216. <pre class="code text"><a name="rest_code_3e93e8d1415445c19b810e7762374be9-1"></a>{{% chart Bar title='Browser usage evolution (in %)' data_file="posts/browsers.json" %}}
  1217. {{% /chart %}}
  1218. </pre>
  1219. <p>If the data or any option is available in both the <code class="docutils literal">data_file</code> and the document, the document has priority.</p>
  1220. </dd>
  1221. <dt>doc</dt>
  1222. <dd>
  1223. <p>Will link to a document in the page, see <a class="reference external" href="handbook.html#doc">Doc role for details</a>. Example:</p>
  1224. <pre class="code restructuredtext"><a name="rest_code_9a52aaf6ba0c4feb8197767861859270-1"></a>Take a look at {{% doc %}}my other post <creating-a-theme>{{% /doc %}} about theme creating.
  1225. </creating-a-theme></pre>
  1226. </dd>
  1227. <dt>emoji</dt>
  1228. <dd>
  1229. <p>Insert an emoji. For example:</p>
  1230. <pre class="code text"><a name="rest_code_e4464a529059439cbf1348acd5c66852-1"></a>{{% emoji crying_face %}}
  1231. </pre>
  1232. <p>This generates a <code class="docutils literal">span</code> with <code class="docutils literal">emoji</code> CSS class, so you can style it with a nice font if you want.</p>
  1233. </dd>
  1234. <dt>gist</dt>
  1235. <dd>
  1236. <p>Show GitHub gists. If you know the gist's ID, this will show it in your site:</p>
  1237. <pre class="code text"><a name="rest_code_ee980f0114414247915df0035769e2e6-1"></a>{{% gist 2395294 %}}
  1238. </pre>
  1239. </dd>
  1240. <dt>listing</dt>
  1241. <dd>
  1242. <p>Used to show a code listing. Example:</p>
  1243. <pre class="code text"><a name="rest_code_2969e45f45a44461bd525578ddd28a35-1"></a>{{% listing hello.py python linenumbers=True %}}
  1244. </pre>
  1245. <p>It takes a file name or path, an optional language to highlight, and a linenumbers option to enable/disable line numbers in the output.</p>
  1246. </dd>
  1247. <dt>media</dt>
  1248. <dd>
  1249. <p>Display media embedded from a URL, for example, this will embed a youtube video:</p>
  1250. <pre class="code text"><a name="rest_code_5b57f4c40c5a446da8740b141360f2ca-1"></a>{{% media url=https://www.youtube.com/watch?v=Nck6BZga7TQ %}}
  1251. </pre>
  1252. <p>Note that the shortcode won’t work if your compiler turns URLs into clickable links.</p>
  1253. </dd>
  1254. <dt>post-list</dt>
  1255. <dd>
  1256. <p>Will show a list of posts, see the <a class="reference external" href="handbook.html#post-list">Post List directive for details</a>.</p>
  1257. </dd>
  1258. <dt>raw</dt>
  1259. <dd>
  1260. <p>Passes the content along, mostly used so I can write this damn section and you can see the shortcodes instead
  1261. of them being munged into shortcode <strong>output</strong>. I can't show an example because Inception.</p>
  1262. </dd>
  1263. <dt>thumbnail</dt>
  1264. <dd>
  1265. <p>Display image thumbnails, with optional captions. Examples:</p>
  1266. <pre class="code text"><a name="rest_code_1361b6c7517446d598a599277dcd9727-1"></a>{{% thumbnail "/images/foo.png" %}}{{% /thumbnail %}}
  1267. <a name="rest_code_1361b6c7517446d598a599277dcd9727-2"></a>{{% thumbnail "/images/foo.png" alt="Foo Image" align="center" %}}{{% /thumbnail %}}
  1268. <a name="rest_code_1361b6c7517446d598a599277dcd9727-3"></a>{{% thumbnail "/images/foo.png" imgclass="image-grayscale" figclass="figure-shadow" %}}&lt;p&gt;Image caption&lt;/p&gt;{{% /thumbnail %}}
  1269. <a name="rest_code_1361b6c7517446d598a599277dcd9727-4"></a>{{% thumbnail "/images/foo.png" alt="Foo Image" title="Insert title-text joke here" align="right" %}}&lt;p class="caption"&gt;Foo Image (right-aligned) caption&lt;/p&gt;{{% /thumbnail %}}
  1270. </pre>
  1271. <p>The following keyword arguments are supported:</p>
  1272. <ul class="simple">
  1273. <li><p>alt (alt text for image)</p></li>
  1274. <li><p>align (image alignment, left/center/right)</p></li>
  1275. <li><p>linktitle (title text for the link, shown by e.g. baguetteBox)</p></li>
  1276. <li><p>title (title text for image)</p></li>
  1277. <li><p>imgclass (class for image)</p></li>
  1278. <li><p>figclass (class for figure, used only if you provide a caption)</p></li>
  1279. </ul>
  1280. <p>Looks similar to the reST thumbnail directive. Caption should be a HTML fragment.</p>
  1281. </dd>
  1282. </dl></section><section id="community-shortcodes"><h3><a class="toc-backref" href="handbook.html#toc-entry-49" role="doc-backlink">Community shortcodes</a></h3>
  1283. <p>Shortcodes created by the community are available in <a class="reference external" href="https://github.com/getnikola/shortcodes">the shortcodes repository on GitHub</a>.</p>
  1284. </section><section id="template-based-shortcodes"><h3><a class="toc-backref" href="handbook.html#toc-entry-50" role="doc-backlink">Template-based shortcodes</a></h3>
  1285. <p>If you put a template in <code class="docutils literal">shortcodes/</code> called <code class="docutils literal">mycode.tmpl</code> then Nikola
  1286. will create a shortcode called <code class="docutils literal">mycode</code> you can use. Any options you pass to
  1287. the shortcode will be available as variables for that template. Non-keyword
  1288. options will be passed in a tuple variable named <code class="docutils literal">_args</code>.</p>
  1289. <p>The post in which the shortcode is being used is available as the <code class="docutils literal">post</code>
  1290. variable, so you can access the title as <code class="docutils literal">post.title</code>, and data loaded
  1291. via the <code class="docutils literal">data</code> field in the metadata using <code class="docutils literal">post.data(key)</code>.</p>
  1292. <p>If you use the shortcode as paired, then the contents between the paired tags
  1293. will be available in the <code class="docutils literal">data</code> variable. If you want to access the Nikola
  1294. object, it will be available as <code class="docutils literal">site</code>. Use with care :-)</p>
  1295. <aside class="admonition note"><p class="admonition-title">Note</p>
  1296. <p>Template-based shortcodes use the same template engine as your site’s theme.</p>
  1297. </aside><p>See <a class="reference external" href="extending.html">Extending Nikola</a> for detailed information.</p>
  1298. <p>For example, if your <code class="docutils literal">shortcodes/foo.tmpl</code> contains this:</p>
  1299. <pre class="code text"><a name="rest_code_6035c8ab23004e31be536b9f949cdba5-1"></a>This uses the bar variable: ${bar}
  1300. </pre>
  1301. <p>And your post contains this:</p>
  1302. <pre class="code text"><a name="rest_code_0bb098b26f0347419ebbf54484a32c1a-1"></a>{{% foo bar=bla %}}
  1303. </pre>
  1304. <p>Then the output file will contain:</p>
  1305. <pre class="code text"><a name="rest_code_0adb60b492ec499d93accd1efb9fcf9d-1"></a>This uses the bar variable: bla
  1306. </pre>
  1307. <p>Finally, you can use a template shortcode without a file, by inserting the
  1308. template in the shortcode itself:</p>
  1309. <pre class="code html+mako"><a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-1"></a>{{% template %}}
  1310. <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-2"></a><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
  1311. <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-3"></a><span class="cp">%</span> <span class="k">for</span> <span class="n">foo</span> <span class="ow">in</span> <span class="n">bar</span><span class="p">:</span>
  1312. <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-4"></a><span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">foo</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
  1313. <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-5"></a><span class="cp">%</span><span class="k"> endfor</span>
  1314. <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-6"></a><span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
  1315. <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-7"></a>{{% /template %}}
  1316. </pre>
  1317. <p>In that case, the template engine used will be your theme's and the arguments you pass,
  1318. as well as the global context from your <code class="docutils literal">conf.py</code>, are available to the template you
  1319. are creating.</p>
  1320. <p>You can use anything defined in your configuration's <code class="docutils literal">GLOBAL_CONTEXT</code> as
  1321. variables in your shortcode template, with a caveat: Because of an unfortunate
  1322. implementation detail (a name conflict), <code class="docutils literal">data</code> is called <code class="docutils literal">global_data</code>
  1323. when used in a shortcode.</p>
  1324. <p>If you have some template code that you want to appear in both a template and
  1325. shortcode, you can put the shared code in a separate template and import it in both
  1326. places. Shortcodes can import any template inside <code class="docutils literal">templates/</code> and themes,
  1327. and call any macros defined in those.</p>
  1328. <p>For example, if you define a macro <code class="docutils literal">foo(x, y)</code> in
  1329. <code class="docutils literal">templates/shared_sc.tmpl</code>, you can include <code class="docutils literal">shared_foo.tmpl</code> in
  1330. <code class="docutils literal">templates/special_post.tmpl</code> and <code class="docutils literal">shortcodes/foo.tmpl</code> and then call the
  1331. <code class="docutils literal">${shared_foo.foo(x, y)}</code> macro.</p>
  1332. </section></section><section id="the-global-context-and-data-files"><h2><a class="toc-backref" href="handbook.html#toc-entry-51" role="doc-backlink">The Global Context and Data files</a></h2>
  1333. <p>There is a <code class="docutils literal">GLOBAL_CONTEXT</code> field in your <code class="docutils literal">conf.py</code> where you can
  1334. put things you want to make available to your templates.</p>
  1335. <p>It will also contain things you put in a <code class="docutils literal">data/</code> directory within your
  1336. site. You can use JSON, YAML or TOML files (with the appropriate file
  1337. extensions: json/js, yaml/yml, toml/tml) that decode to Python dictionaries.
  1338. For example, if you create <code class="docutils literal">data/foo.json</code> containing this:</p>
  1339. <pre class="code json"><a name="rest_code_4dc650e3a20246fd809ef23aad762f0e-1"></a><span class="p">{</span><span class="nt">"bar"</span><span class="p">:</span> <span class="s2">"baz"</span><span class="p">}</span>
  1340. </pre>
  1341. <p>Then your templates can use things like <code class="docutils literal"><span class="pre">${data['foo']['bar']}</span></code> and
  1342. it will be replaced by "baz".</p>
  1343. <p>Individual posts can also have a data file. Those are specified using the
  1344. <code class="docutils literal">data</code> meta field (path relative to <code class="docutils literal">conf.py</code>, can be different in
  1345. different post languages). Those are accessible as eg.
  1346. <code class="docutils literal"><span class="pre">${post.data['bar']}</span></code> in templates. <a class="reference internal" href="handbook.html#template-based-shortcodes">Template-based shortcodes</a> are a
  1347. good idea in this case.</p>
  1348. <p>Data files can be useful for eg. auto-generated sites, where users provide
  1349. JSON/YAML/TOML files and Nikola generates a large page with data from all data
  1350. files. (This is especially useful with some automatic rebuild feature, like
  1351. those documented in <a class="reference internal" href="handbook.html#deployment">Deployment</a>)</p>
  1352. <p>Data files are also available as <code class="docutils literal">global_data</code>, to avoid name conflicts in
  1353. shortcodes. (<code class="docutils literal">global_data</code> works everywhere.)</p>
  1354. </section><section id="redirections"><h2><a class="toc-backref" href="handbook.html#toc-entry-52" role="doc-backlink">Redirections</a></h2>
  1355. <p>If you need a page to be available in more than one place, you can define redirections
  1356. in your <code class="docutils literal">conf.py</code>:</p>
  1357. <pre class="code python"><a name="rest_code_f95788d007ac4386a97f12dc20469dac-1"></a><span class="c1"># A list of redirection tuples, [("foo/from.html", "/bar/to.html")].</span>
  1358. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-2"></a><span class="c1">#</span>
  1359. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-3"></a><span class="c1"># A HTML file will be created in output/foo/from.html that redirects</span>
  1360. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-4"></a><span class="c1"># to the "/bar/to.html" URL. notice that the "from" side MUST be a</span>
  1361. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-5"></a><span class="c1"># relative URL.</span>
  1362. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-6"></a><span class="c1">#</span>
  1363. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-7"></a><span class="c1"># If you don't need any of these, just set to []</span>
  1364. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-8"></a>
  1365. <a name="rest_code_f95788d007ac4386a97f12dc20469dac-9"></a><span class="n">REDIRECTIONS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"index.html"</span><span class="p">,</span> <span class="s2">"/weblog/index.html"</span><span class="p">)]</span>
  1366. </pre>
  1367. <p>It's better if you can do these using your web server's configuration, but if
  1368. you can't, this will work.</p>
  1369. </section><section id="configuration"><h2><a class="toc-backref" href="handbook.html#toc-entry-53" role="doc-backlink">Configuration</a></h2>
  1370. <p>The configuration file can be used to customize a lot of what Nikola does. Its
  1371. syntax is python, but if you don't know the language, it still should not be
  1372. terribly hard to grasp.</p>
  1373. <p>By default, the <code class="docutils literal">conf.py</code> file in the root of the Nikola website will be used.
  1374. You can pass a different configuration file to by using the <code class="docutils literal"><span class="pre">--conf</span></code> command line switch.</p>
  1375. <p>The default <code class="docutils literal">conf.py</code> you get with Nikola should be fairly complete, and is quite
  1376. commented.</p>
  1377. <p>You surely want to edit these options:</p>
  1378. <pre class="code python"><a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-1"></a><span class="c1"># Data about this site</span>
  1379. <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-2"></a><span class="n">BLOG_AUTHOR</span> <span class="o">=</span> <span class="s2">"Your Name"</span> <span class="c1"># (translatable)</span>
  1380. <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-3"></a><span class="n">BLOG_TITLE</span> <span class="o">=</span> <span class="s2">"Demo Site"</span> <span class="c1"># (translatable)</span>
  1381. <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-4"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"https://getnikola.com/"</span>
  1382. <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-5"></a><span class="n">BLOG_EMAIL</span> <span class="o">=</span> <span class="s2">"joe@demo.site"</span>
  1383. <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-6"></a><span class="n">BLOG_DESCRIPTION</span> <span class="o">=</span> <span class="s2">"This is a demo site for Nikola."</span> <span class="c1"># (translatable)</span>
  1384. </pre>
  1385. <p>Some options are marked with a (translatable) comment above or right next to
  1386. them. For those options, two types of values can be provided:</p>
  1387. <ul class="simple">
  1388. <li><p>a string, which will be used for all languages</p></li>
  1389. <li><p>a dict of language-value pairs, to have different values in each language</p></li>
  1390. </ul>
  1391. <aside class="admonition note"><p class="admonition-title">Note</p>
  1392. <p>As of version 8.0.3 it is possible to create configuration files which inherit values from other Python files.
  1393. This might be useful if you're working with similar environments.</p>
  1394. <dl>
  1395. <dt>Example:</dt>
  1396. <dd><dl>
  1397. <dt>conf.py:</dt>
  1398. <dd><pre class="code python"><a name="rest_code_87474c99ec32407e8f46318d9078dc38-1"></a><span class="n">BLOG_AUTHOR</span> <span class="o">=</span> <span class="s2">"Your Name"</span>
  1399. <a name="rest_code_87474c99ec32407e8f46318d9078dc38-2"></a><span class="n">BLOG_TITLE</span> <span class="o">=</span> <span class="s2">"Demo Site"</span>
  1400. <a name="rest_code_87474c99ec32407e8f46318d9078dc38-3"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"https://yourname.github.io/demo-site</span>
  1401. <a name="rest_code_87474c99ec32407e8f46318d9078dc38-4"></a><span class="n">BLOG_EMAIL</span> <span class="o">=</span> <span class="s2">"joe@demo.site"</span>
  1402. <a name="rest_code_87474c99ec32407e8f46318d9078dc38-5"></a><span class="n">BLOG_DESCRIPTION</span> <span class="o">=</span> <span class="s2">"This is a demo site for Nikola."</span>
  1403. </pre></dd>
  1404. <dt>debug.conf.py:</dt>
  1405. <dd>
  1406. <pre class="code python"><a name="rest_code_cfcf7893d7434f33aff1a30ef65edc10-1"></a><span class="kn">import</span> <span class="nn">conf</span>
  1407. <a name="rest_code_cfcf7893d7434f33aff1a30ef65edc10-2"></a><span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="nb">vars</span><span class="p">(</span><span class="n">conf</span><span class="p">))</span>
  1408. <a name="rest_code_cfcf7893d7434f33aff1a30ef65edc10-3"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"http://localhost:8000/"</span>
  1409. </pre>
  1410. <p>or</p>
  1411. <pre class="code python"><a name="rest_code_7263480f318a4ad2808bb1440153a1f8-1"></a><span class="kn">from</span> <span class="nn">conf</span> <span class="kn">import</span> <span class="o">*</span>
  1412. <a name="rest_code_7263480f318a4ad2808bb1440153a1f8-2"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"http://localhost:8000/"</span>
  1413. </pre>
  1414. </dd>
  1415. </dl></dd>
  1416. </dl></aside></section><section id="customizing-your-site"><h2><a class="toc-backref" href="handbook.html#toc-entry-54" role="doc-backlink">Customizing Your Site</a></h2>
  1417. <p>There are lots of things you can do to personalize your website, but let's see
  1418. the easy ones!</p>
  1419. <dl>
  1420. <dt>CSS tweaking</dt>
  1421. <dd>
  1422. <p>Using the default configuration, you can create a <code class="docutils literal">assets/css/custom.css</code>
  1423. file under <code class="docutils literal">files/</code> or in your theme and then it will be loaded from the
  1424. <code class="docutils literal">&lt;head&gt;</code> blocks of your site pages. Create it and put your CSS code there,
  1425. for minimal disruption of the provided CSS files.</p>
  1426. <p>If you feel tempted to touch other files in assets, you probably will be better off
  1427. with a <a class="reference external" href="theming.html">custom theme</a>.</p>
  1428. <p>If you want to use <a class="reference external" href="http://lesscss.org/">LESS</a> or <a class="reference external" href="https://sass-lang.com/">Sass</a> for your custom CSS, or the theme you use
  1429. contains LESS or Sass code that you want to override, you will need to install
  1430. the <a class="reference external" href="https://plugins.getnikola.com/#less">LESS plugin</a> or
  1431. <a class="reference external" href="https://plugins.getnikola.com/#sass">SASS plugin</a> create a <code class="docutils literal">less</code> or
  1432. <code class="docutils literal">sass</code> directory in your site root, put your <code class="docutils literal">.less</code> or <code class="docutils literal">.scss</code> files
  1433. there and a targets file containing the list of files you want compiled.</p>
  1434. </dd>
  1435. </dl>
  1436. <dl>
  1437. <dt>Template tweaking and creating themes</dt>
  1438. <dd>
  1439. <p>If you really want to change the pages radically, you will want to do a
  1440. <a class="reference external" href="theming.html">custom theme</a>.</p>
  1441. </dd>
  1442. <dt>Navigation Links</dt>
  1443. <dd>
  1444. <p>The <code class="docutils literal">NAVIGATION_LINKS</code> option lets you define what links go in a sidebar or menu
  1445. (depending on your theme) so you can link to important pages, or to other sites.</p>
  1446. <p>The format is a language-indexed dictionary, where each element is a tuple of
  1447. tuples which are one of:</p>
  1448. <ol class="arabic simple">
  1449. <li><p>A (url, text) tuple, describing a link</p></li>
  1450. <li><p>A (((url, text), (url, text), (url, text)), title) tuple, describing a submenu / sublist.</p></li>
  1451. </ol>
  1452. <p>Example:</p>
  1453. <pre class="code python"><a name="rest_code_2ac806e68e064632b07a82714691b167-1"></a><span class="n">NAVIGATION_LINKS</span> <span class="o">=</span> <span class="p">{</span>
  1454. <a name="rest_code_2ac806e68e064632b07a82714691b167-2"></a> <span class="n">DEFAULT_LANG</span><span class="p">:</span> <span class="p">(</span>
  1455. <a name="rest_code_2ac806e68e064632b07a82714691b167-3"></a> <span class="p">(</span><span class="s1">'/archive.html'</span><span class="p">,</span> <span class="s1">'Archives'</span><span class="p">),</span>
  1456. <a name="rest_code_2ac806e68e064632b07a82714691b167-4"></a> <span class="p">(</span><span class="s1">'/categories/index.html'</span><span class="p">,</span> <span class="s1">'Tags'</span><span class="p">),</span>
  1457. <a name="rest_code_2ac806e68e064632b07a82714691b167-5"></a> <span class="p">(</span><span class="s1">'/rss.xml'</span><span class="p">,</span> <span class="s1">'RSS'</span><span class="p">),</span>
  1458. <a name="rest_code_2ac806e68e064632b07a82714691b167-6"></a> <span class="p">(((</span><span class="s1">'/foo'</span><span class="p">,</span> <span class="s1">'FOO'</span><span class="p">),</span>
  1459. <a name="rest_code_2ac806e68e064632b07a82714691b167-7"></a> <span class="p">(</span><span class="s1">'/bar'</span><span class="p">,</span> <span class="s1">'BAR'</span><span class="p">)),</span> <span class="s1">'BAZ'</span><span class="p">),</span>
  1460. <a name="rest_code_2ac806e68e064632b07a82714691b167-8"></a> <span class="p">),</span>
  1461. <a name="rest_code_2ac806e68e064632b07a82714691b167-9"></a><span class="p">}</span>
  1462. </pre>
  1463. <aside class="admonition note"><p class="admonition-title">Note</p>
  1464. <ol class="arabic simple">
  1465. <li><p>Support for submenus is theme-dependent. Only one level of
  1466. submenus is supported.</p></li>
  1467. <li><p>Some themes, including the default Bootstrap theme, may
  1468. present issues if the menu is too large. (in Bootstrap, the navbar
  1469. can grow too large and cover contents.)</p></li>
  1470. <li><p>If you link to directories, make sure to follow <code class="docutils literal">STRIP_INDEXES</code>. If
  1471. it’s set to <code class="docutils literal">True</code>, end your links with a <code class="docutils literal">/</code>, otherwise end them
  1472. with <code class="docutils literal">/index.html</code> — or else they won’t be highlighted when active.</p></li>
  1473. </ol></aside><p>There’s also <code class="docutils literal">NAVIGATION_ALT_LINKS</code>. Themes may display this somewhere
  1474. else, or not at all. Bootstrap puts it on the right side of the header.</p>
  1475. <p>The <code class="docutils literal">SEARCH_FORM</code> option contains the HTML code for a search form based on
  1476. duckduckgo.com which should always work, but feel free to change it to
  1477. something else.</p>
  1478. </dd>
  1479. <dt>Footer</dt>
  1480. <dd>
  1481. <p><code class="docutils literal">CONTENT_FOOTER</code> is displayed, small at the bottom of all pages, I use it for
  1482. the copyright notice. The default shows a text formed using <code class="docutils literal">BLOG_AUTHOR</code>,
  1483. <code class="docutils literal">BLOG_EMAIL</code>, the date and <code class="docutils literal">LICENSE</code>. Note you need to use
  1484. <code class="docutils literal">CONTENT_FOOTER_FORMATS</code> instead of regular str.format or %-formatting,
  1485. for compatibility with the translatable settings feature.</p>
  1486. </dd>
  1487. <dt>BODY_END</dt>
  1488. <dd>
  1489. <p>This option lets you define a HTML snippet that will be added at the bottom of body.
  1490. The main usage is a Google analytics snippet or something similar, but you can really
  1491. put anything there. Good place for JavaScript.</p>
  1492. </dd>
  1493. <dt>SOCIAL_BUTTONS_CODE</dt>
  1494. <dd>
  1495. <p>The <code class="docutils literal">SOCIAL_BUTTONS_CODE</code> option lets you define a HTML snippet that will be added
  1496. at the bottom of body. It defaults to a snippet for AddThis, but you can
  1497. really put anything there. See <cite>social_buttons.html</cite> for more details.</p>
  1498. </dd>
  1499. </dl></section><section id="fancy-dates"><h2><a class="toc-backref" href="handbook.html#toc-entry-55" role="doc-backlink">Fancy Dates</a></h2>
  1500. <p>Nikola can use various styles for presenting dates.</p>
  1501. <dl class="simple">
  1502. <dt>DATE_FORMAT</dt>
  1503. <dd>
  1504. <p>The date format to use if there is no JS or fancy dates are off. <a class="reference external" href="http://cldr.unicode.org/translation/date-time-1/date-time">Compatible with CLDR syntax.</a></p>
  1505. </dd>
  1506. <dt>LUXON_DATE_FORMAT</dt>
  1507. <dd>
  1508. <p>The date format to use with Luxon. A dictionary of dictionaries: the top level is languages, and the subdictionaries are of the format <code class="docutils literal">{'preset': False, 'format': <span class="pre">'yyyy-MM-dd</span> HH:mm'}</code>. <a class="reference external" href="https://moment.github.io/luxon/docs/manual/formatting">Used by Luxon</a> (format can be the preset name, eg. <code class="docutils literal">'DATE_LONG'</code>).</p>
  1509. </dd>
  1510. <dt>MOMENTJS_DATE_FORMAT (formerly JS_DATE_FORMAT)</dt>
  1511. <dd>
  1512. <p>The date format to use if fancy dates are on, and the theme is using Moment.js.</p>
  1513. </dd>
  1514. <dt>DATE_FANCINESS = 0</dt>
  1515. <dd>
  1516. <p>Fancy dates are off, and DATE_FORMAT is used.</p>
  1517. </dd>
  1518. <dt>DATE_FANCINESS = 1</dt>
  1519. <dd>
  1520. <p>Dates are recalculated in user’s timezone. Requires JavaScript.</p>
  1521. </dd>
  1522. <dt>DATE_FANCINESS = 2</dt>
  1523. <dd>
  1524. <p>Dates are recalculated as relative time (eg. 2 days ago). Requires JavaScript.</p>
  1525. </dd>
  1526. </dl>
  1527. <p>In order to use fancy dates, your theme must support them. The built-in Bootstrap family supports it, but other themes might not by default.</p>
  1528. <p>For Mako:</p>
  1529. <pre class="code html"><a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-1"></a>% if date_fanciness != 0:
  1530. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-2"></a>%if date_fanciness == 2:
  1531. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-3"></a> <span class="c">&lt;!-- Polyfill for relative dates in Safari -- best handled with a CDN --&gt;</span>
  1532. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-4"></a> <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://polyfill.io/v3/polyfill.js?features=Intl.RelativeTimeFormat.%7Elocale.${luxon_locales[lang]}"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1533. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-5"></a>%endif
  1534. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-6"></a><span class="c">&lt;!-- required scripts -- best handled with bundles --&gt;</span>
  1535. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-7"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/luxon.min.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1536. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-8"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/fancydates.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1537. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-9"></a>
  1538. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-10"></a><span class="c">&lt;!-- fancy dates code --&gt;</span>
  1539. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-11"></a><span class="p">&lt;</span><span class="nt">script</span><span class="p">&gt;</span>
  1540. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-12"></a><span class="nx">luxon</span><span class="p">.</span><span class="nx">Settings</span><span class="p">.</span><span class="nx">defaultLocale</span> <span class="o">=</span> <span class="s2">"${luxon_locales[lang]}"</span><span class="p">;</span>
  1541. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-13"></a><span class="nx">fancydates</span><span class="p">(</span><span class="nx">$</span><span class="p">{</span><span class="nx">date_fanciness</span><span class="p">},</span> <span class="nx">$</span><span class="p">{</span><span class="nx">luxon_date_format</span><span class="p">});</span>
  1542. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-14"></a><span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1543. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-15"></a><span class="c">&lt;!-- end fancy dates code --&gt;</span>
  1544. <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-16"></a>%endif
  1545. </pre>
  1546. <p>For Jinja2:</p>
  1547. <pre class="code html"><a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-1"></a>{% if date_fanciness != 0 %}
  1548. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-2"></a>{% if date_fanciness == 2 %}
  1549. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-3"></a> <span class="c">&lt;!-- Polyfill for relative dates in Safari -- best handled with a CDN --&gt;</span>
  1550. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-4"></a> <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://polyfill.io/v3/polyfill.js?features=Intl.RelativeTimeFormat.%7Elocale.{{ luxon_locales[lang] }}"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1551. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-5"></a>{% endif %}
  1552. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-6"></a><span class="c">&lt;!-- required scripts -- best handled with bundles --&gt;</span>
  1553. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-7"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/luxon.min.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1554. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-8"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/fancydates.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1555. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-9"></a>
  1556. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-10"></a><span class="c">&lt;!-- fancy dates code --&gt;</span>
  1557. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-11"></a><span class="p">&lt;</span><span class="nt">script</span><span class="p">&gt;</span>
  1558. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-12"></a><span class="nx">luxon</span><span class="p">.</span><span class="nx">Settings</span><span class="p">.</span><span class="nx">defaultLocale</span> <span class="o">=</span> <span class="s2">"{{ luxon_locales[lang] }}"</span><span class="p">;</span>
  1559. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-13"></a><span class="nx">fancydates</span><span class="p">({{</span> <span class="nx">date_fanciness</span> <span class="p">}},</span> <span class="p">{{</span> <span class="nx">luxon_date_format</span> <span class="p">}});</span>
  1560. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-14"></a><span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  1561. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-15"></a><span class="c">&lt;!-- end fancy dates code --&gt;</span>
  1562. <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-16"></a>{% endif %}
  1563. </pre></section><section id="adding-files"><h2><a class="toc-backref" href="handbook.html#toc-entry-56" role="doc-backlink">Adding Files</a></h2>
  1564. <p>Any files you want to be in <code class="docutils literal">output/</code> but are not generated by Nikola (for
  1565. example, <code class="docutils literal">favicon.ico</code>) should be placed in <code class="docutils literal">files/</code>. Remember that you
  1566. can't have files that collide with files Nikola generates (it will give an
  1567. error).</p>
  1568. <aside class="admonition admonition-important"><p class="admonition-title">Important</p>
  1569. <p>Don't put any files manually in <code class="docutils literal">output/</code>. Ever. Really.
  1570. Maybe someday Nikola will just wipe <code class="docutils literal">output/</code> (when you run <code class="docutils literal">nikola check <span class="pre">-f</span> <span class="pre">--clean-files</span></code>) and then you will be sorry. So, please don't do that.</p>
  1571. </aside><p>If you want to copy more than one folder of static files into <code class="docutils literal">output</code> you can
  1572. change the FILES_FOLDERS option:</p>
  1573. <pre class="code python"><a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-1"></a><span class="c1"># One or more folders containing files to be copied as-is into the output.</span>
  1574. <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-2"></a><span class="c1"># The format is a dictionary of "source" "relative destination".</span>
  1575. <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-3"></a><span class="c1"># Default is:</span>
  1576. <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-4"></a><span class="c1"># FILES_FOLDERS = {'files': '' }</span>
  1577. <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-5"></a><span class="c1"># Which means copy 'files' into 'output'</span>
  1578. </pre></section><section id="custom-themes"><h2><a class="toc-backref" href="handbook.html#toc-entry-57" role="doc-backlink">Custom Themes</a></h2>
  1579. <p>If you prefer to have a custom appearance for your site, and modifying CSS
  1580. files and settings (see <a class="reference internal" href="handbook.html#customizing-your-site">Customizing Your Site</a> for details) is not enough,
  1581. you can create your own theme. See the <a class="reference external" href="theming.html">Theming Nikola</a> and
  1582. <a class="reference external" href="creating-a-theme.html">Creating a Theme</a> for more details. You can put them in a <code class="docutils literal">themes/</code>
  1583. folder and set <code class="docutils literal">THEME</code> to the directory name. You can also put them in
  1584. directories listed in the <code class="docutils literal">EXTRA_THEMES_DIRS</code> configuration variable.</p>
  1585. </section><section id="getting-extra-themes"><h2><a class="toc-backref" href="handbook.html#toc-entry-58" role="doc-backlink">Getting Extra Themes</a></h2>
  1586. <p>There are a few themes for Nikola. They are available at
  1587. the <a class="reference external" href="https://themes.getnikola.com/">Themes Index</a>.
  1588. Nikola has a built-in theme download/install mechanism to install those themes
  1589. — the <code class="docutils literal">theme</code> command:</p>
  1590. <pre class="code console"><a name="rest_code_f2f92738a0074fba924eafed3daacedb-1"></a><span class="gp">$</span> nikola theme -l
  1591. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-2"></a><span class="go">Themes:</span>
  1592. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-3"></a><span class="go">-------</span>
  1593. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-4"></a><span class="go">blogtxt</span>
  1594. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-5"></a><span class="go">bootstrap3-gradients</span>
  1595. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-6"></a><span class="go">⋮</span>
  1596. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-7"></a><span class="go">⋮</span>
  1597. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-8"></a>
  1598. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-9"></a><span class="gp">$</span> nikola theme -i blogtxt
  1599. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-10"></a><span class="go">[2013-10-12T16:46:13Z] NOTICE: theme: Downloading:</span>
  1600. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-11"></a><span class="go">https://themes.getnikola.com/v6/blogtxt.zip</span>
  1601. <a name="rest_code_f2f92738a0074fba924eafed3daacedb-12"></a><span class="go">[2013-10-12T16:46:15Z] NOTICE: theme: Extracting: blogtxt into themes</span>
  1602. </pre>
  1603. <p>And there you are, you now have themes/blogtxt installed. It's very
  1604. rudimentary, but it should work in most cases.</p>
  1605. <p>If you create a nice theme, please share it! You can do it as a pull
  1606. request in the <a class="reference external" href="https://github.com/getnikola/nikola-themes">GitHub repository</a>.</p>
  1607. <p>One other option is to tweak an existing theme using a different color scheme,
  1608. typography and CSS in general. Nikola provides a <code class="docutils literal">subtheme</code> command
  1609. to create a custom theme by downloading free CSS files from <a class="reference external" href="https://bootswatch.com">https://bootswatch.com</a>
  1610. and <a class="reference external" href="https://hackerthemes.com">https://hackerthemes.com</a></p>
  1611. <pre class="code console"><a name="rest_code_f85a98af5f764ca581778646283fe1d4-1"></a><span class="gp">$</span> nikola subtheme -n custom_theme -s flatly -p bootstrap4
  1612. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-2"></a><span class="go">[2013-10-12T16:46:58Z] NOTICE: subtheme: Creating 'custom_theme' theme</span>
  1613. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-3"></a><span class="go">from 'flatly' and 'bootstrap4'</span>
  1614. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-4"></a><span class="go">[2013-10-12T16:46:58Z] NOTICE: subtheme: Downloading:</span>
  1615. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-5"></a><span class="go">http://bootswatch.com/flatly/bootstrap.min.css</span>
  1616. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-6"></a><span class="go">[2013-10-12T16:46:58Z] NOTICE: subtheme: Downloading:</span>
  1617. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-7"></a><span class="go">http://bootswatch.com/flatly/bootstrap.css</span>
  1618. <a name="rest_code_f85a98af5f764ca581778646283fe1d4-8"></a><span class="go">[2013-10-12T16:46:59Z] NOTICE: subtheme: Theme created. Change the THEME setting to "custom_theme" to use it.</span>
  1619. </pre>
  1620. <p>Play with it, there's cool stuff there. This feature was suggested by
  1621. <a class="reference external" href="http://elgalpondebanquito.com.ar">clodo</a>.</p>
  1622. </section><section id="deployment"><h2><a class="toc-backref" href="handbook.html#toc-entry-59" role="doc-backlink">Deployment</a></h2>
  1623. <p>If you can specify your deployment procedure as a series of commands, you can
  1624. put them in the <code class="docutils literal">DEPLOY_COMMANDS</code> option, and run them with <code class="docutils literal">nikola deploy</code>.</p>
  1625. <p>You can have multiple deployment presets. If you run <code class="docutils literal">nikola deploy</code>, the
  1626. <code class="docutils literal">default</code> preset is executed. You can also specify the names of presets
  1627. you want to run (eg. <code class="docutils literal">nikola deploy default</code>, multiple presets are allowed).</p>
  1628. <p>One caveat is that if any command has a % in it, you should double them.</p>
  1629. <p>Here is an example, from my own site's deployment script:</p>
  1630. <pre class="code python"><a name="rest_code_59a2999f62f44b56ac9e57ae60039238-1"></a><span class="n">DEPLOY_COMMANDS</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'default'</span><span class="p">:</span> <span class="p">[</span>
  1631. <a name="rest_code_59a2999f62f44b56ac9e57ae60039238-2"></a> <span class="s1">'rsync -rav --delete output/ ralsina@lateral.netmanagers.com.ar:/srv/www/lateral'</span><span class="p">,</span>
  1632. <a name="rest_code_59a2999f62f44b56ac9e57ae60039238-3"></a> <span class="s1">'rdiff-backup output ~/blog-backup'</span><span class="p">,</span>
  1633. <a name="rest_code_59a2999f62f44b56ac9e57ae60039238-4"></a> <span class="s2">"links -dump 'http://www.twingly.com/ping2?url=lateral.netmanagers.com.ar'"</span><span class="p">,</span>
  1634. <a name="rest_code_59a2999f62f44b56ac9e57ae60039238-5"></a><span class="p">]}</span>
  1635. </pre>
  1636. <p>Other interesting ideas are using
  1637. <a class="reference external" href="https://toroid.org/git-website-howto">git as a deployment mechanism</a> (or any other VCS
  1638. for that matter), using <a class="reference external" href="https://lftp.yar.ru/">lftp mirror</a> or unison, or Dropbox.
  1639. Any way you can think of to copy files from one place to another is good enough.</p>
  1640. <section id="deploying-to-github"><h3><a class="toc-backref" href="handbook.html#toc-entry-60" role="doc-backlink">Deploying to GitHub</a></h3>
  1641. <p>Nikola provides a separate command <code class="docutils literal">github_deploy</code> to deploy your site to
  1642. GitHub Pages. The command builds the site, commits the output to a gh-pages
  1643. branch and pushes the output to GitHub. Nikola uses the <a class="reference external" href="https://github.com/davisp/ghp-import">ghp-import command</a> for this.</p>
  1644. <p>In order to use this feature, you need to configure a few things first. Make
  1645. sure you have <code class="docutils literal">nikola</code> and <code class="docutils literal">git</code> installed on your PATH.</p>
  1646. <ol class="arabic">
  1647. <li><p>Initialize a Nikola site, if you haven’t already.</p></li>
  1648. <li>
  1649. <p>Initialize a git repository in your Nikola source directory by running:</p>
  1650. <pre class="code text"><a name="rest_code_a15b8909505542b9a3d2dab06521e85e-1"></a>git init .
  1651. <a name="rest_code_a15b8909505542b9a3d2dab06521e85e-2"></a>git remote add origin git@github.com:user/repository.git
  1652. </pre>
  1653. </li>
  1654. <li>
  1655. <p>Setup branches and remotes in <code class="docutils literal">conf.py</code>:</p>
  1656. <ul class="simple">
  1657. <li><p><code class="docutils literal">GITHUB_DEPLOY_BRANCH</code> is the branch where Nikola-generated HTML files
  1658. will be deployed. It should be <code class="docutils literal"><span class="pre">gh-pages</span></code> for project pages and
  1659. <code class="docutils literal">master</code> for user pages (user.github.io).</p></li>
  1660. <li><p><code class="docutils literal">GITHUB_SOURCE_BRANCH</code> is the branch where your Nikola site source will be
  1661. deployed. We recommend and default to <code class="docutils literal">src</code>.</p></li>
  1662. <li><p><code class="docutils literal">GITHUB_REMOTE_NAME</code> is the remote to which changes are pushed.</p></li>
  1663. <li><p><code class="docutils literal">GITHUB_COMMIT_SOURCE</code> controls whether or not the source branch is
  1664. automatically committed to and pushed. We recommend setting it to
  1665. <code class="docutils literal">True</code>, unless you are automating builds with CI (eg. GitHub Actions/GitLab CI).</p></li>
  1666. </ul>
  1667. </li>
  1668. <li>
  1669. <p>Create a <code class="docutils literal">.gitignore</code> file. We recommend adding at least the following entries:</p>
  1670. <pre class="code text"><a name="rest_code_90245400f63d48fb926bf20a090dd223-1"></a>cache
  1671. <a name="rest_code_90245400f63d48fb926bf20a090dd223-2"></a>.doit.db
  1672. <a name="rest_code_90245400f63d48fb926bf20a090dd223-3"></a>__pycache__
  1673. <a name="rest_code_90245400f63d48fb926bf20a090dd223-4"></a>output
  1674. </pre>
  1675. </li>
  1676. <li><p>If you set <code class="docutils literal">GITHUB_COMMIT_SOURCE</code> to False, you must switch to your source
  1677. branch and commit to it. Otherwise, this is done for you.</p></li>
  1678. <li><p>Run <code class="docutils literal">nikola github_deploy</code>. This will build the site, commit the output
  1679. folder to your deploy branch, and push to GitHub. Your website should be up
  1680. and running within a few minutes.</p></li>
  1681. </ol>
  1682. <p>If you want to use a custom domain, create your <code class="docutils literal">CNAME</code> file in
  1683. <code class="docutils literal">files/CNAME</code> on the source branch. Nikola will copy it to the
  1684. output directory. To add a custom commit message, use the <code class="docutils literal"><span class="pre">-m</span></code> option,
  1685. followed by your message.</p>
  1686. </section><section id="automated-rebuilds-github-actions-gitlab"><h3><a class="toc-backref" href="handbook.html#toc-entry-61" role="doc-backlink">Automated rebuilds (GitHub Actions, GitLab)</a></h3>
  1687. <p>If you want automated rebuilds and GitHub Pages deployment, allowing you to
  1688. blog from anywhere in the world, you have multiple options:</p>
  1689. <ul class="simple">
  1690. <li><p><a class="reference external" href="https://getnikola.com/blog/automating-nikola-rebuilds-with-github-actions.html">Automating Nikola rebuilds with GitHub Actions</a> (easier for GitHub)</p></li>
  1691. <li><p><a class="reference external" href="https://gitlab.com/pages/nikola">Example Nikola site for GitLab Pages</a></p></li>
  1692. </ul></section></section><section id="comments"><h2><a class="toc-backref" href="handbook.html#toc-entry-62" role="doc-backlink">Comments</a></h2>
  1693. <p>While Nikola creates static sites, there is a minimum level of user interaction you
  1694. are probably expecting: comments.</p>
  1695. <p>Nikola supports several third party comment systems:</p>
  1696. <ul class="simple">
  1697. <li><p><a class="reference external" href="https://disqus.com">DISQUS</a></p></li>
  1698. <li><p><a class="reference external" href="https://www.intensedebate.com/">IntenseDebate</a></p></li>
  1699. <li><p><a class="reference external" href="https://muut.com/">Muut (Formerly moot)</a></p></li>
  1700. <li><p><a class="reference external" href="https://facebook.com/">Facebook</a></p></li>
  1701. <li><p><a class="reference external" href="https://posativ.org/isso/">Isso</a></p></li>
  1702. <li><p><a class="reference external" href="https://github.com/adtac/commento">Commento</a></p></li>
  1703. <li><p><a class="reference external" href="https://utteranc.es/">Utterances</a></p></li>
  1704. </ul>
  1705. <p>By default it will use DISQUS, but you can change by setting <code class="docutils literal">COMMENT_SYSTEM</code>
  1706. to one of "disqus", "intensedebate", "livefyre", "moot", "facebook", "isso", "commento" or "utterances".
  1707. It is also possible to use a comment system added by a plugin, see the
  1708. <a class="reference external" href="https://plugins.getnikola.com/#cactuscomments">Cactus Comments plugin</a> for an example.</p>
  1709. <aside class="sidebar"><p class="sidebar-title"><code class="docutils literal">COMMENT_SYSTEM_ID</code></p>
  1710. <p>The value of <code class="docutils literal">COMMENT_SYSTEM_ID</code> depends on what comment system you
  1711. are using and you can see it in the system's admin interface.</p>
  1712. <ul class="simple">
  1713. <li><p>For DISQUS, it's called the <strong>shortname</strong></p></li>
  1714. <li><p>For IntenseDebate, it's the <strong>IntenseDebate site acct</strong></p></li>
  1715. <li><p>For Muut, it's your <strong>username</strong></p></li>
  1716. <li><p>For Facebook, you need to <a class="reference external" href="https://developers.facebook.com/apps">create an app</a> (turn off sandbox mode!)
  1717. and get an <strong>App ID</strong></p></li>
  1718. <li><p>For Isso, it's the URL of your Isso instance (must be world-accessible, encoded with
  1719. Punycode (if using Internationalized Domain Names) and <strong>have a trailing slash</strong>,
  1720. default <code class="docutils literal"><span class="pre">http://localhost:8080/</span></code>). You can add custom config options via
  1721. <code class="docutils literal">GLOBAL_CONTEXT</code>, e.g., <code class="docutils literal"><span class="pre">GLOBAL_CONTEXT['isso_config']</span> = <span class="pre">{"require-author":</span> "true"}</code></p></li>
  1722. <li><p>For Commento, it's the URL of the commento instance as required by the <code class="docutils literal">serverUrl</code>
  1723. parameter in commento's documentation.</p></li>
  1724. <li><p>For Utterances, it's the <strong>repo name</strong> (<code class="docutils literal">"org/user"</code>) on GitHub whose
  1725. issue tracker is used for comments. Additional Utterances configuration
  1726. values can be stored in the <code class="docutils literal">GLOBAL_CONTEXT</code>, e.g.,
  1727. <code class="docutils literal"><span class="pre">GLOBAL_CONTEXT['utterances_config']</span> = <span class="pre">{"issue-term":</span> "title",
  1728. "label": "Comments", "theme": <span class="pre">"github-light",</span> "crossorigin": "anonymous")</code>.</p></li>
  1729. </ul></aside><p>To use comments in a visible site, you should register with the service and
  1730. then set the <code class="docutils literal">COMMENT_SYSTEM_ID</code> option.</p>
  1731. <p>I recommend 3rd party comments, and specially DISQUS because:</p>
  1732. <ol class="arabic simple">
  1733. <li><p>It doesn't require any server-side software on your site</p></li>
  1734. <li><p>They offer you a way to export your comments, so you can take
  1735. them with you if you need to.</p></li>
  1736. <li><p>It's free.</p></li>
  1737. <li><p>It's damn nice.</p></li>
  1738. </ol>
  1739. <p>You can disable comments for a post by adding a "nocomments" metadata field to it:</p>
  1740. <pre class="code restructuredtext"><a name="rest_code_525b990adf414fd08e4d6266a1116147-1"></a><span class="cp">.. nocomments: True</span>
  1741. </pre>
  1742. <aside class="admonition admonition-disqus-support"><p class="admonition-title">DISQUS Support</p>
  1743. <p>In some cases, when you run the test site, you won't see the comments.
  1744. That can be fixed by adding the disqus_developer flag to the templates
  1745. but it's probably more trouble than it's worth.</p>
  1746. </aside><aside class="admonition admonition-moot-support"><p class="admonition-title">Moot Support</p>
  1747. <p>Moot doesn't support comment counts on index pages, and it requires adding
  1748. this to your <code class="docutils literal">conf.py</code>:</p>
  1749. <pre class="code python"><a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-1"></a><span class="n">BODY_END</span> <span class="o">=</span> <span class="s2">"""</span>
  1750. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-2"></a><span class="s2">&lt;script src="//cdn.moot.it/1/moot.min.js"&gt;&lt;/script&gt;</span>
  1751. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-3"></a><span class="s2">"""</span>
  1752. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-4"></a><span class="n">EXTRA_HEAD_DATA</span> <span class="o">=</span> <span class="s2">"""</span>
  1753. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-5"></a><span class="s2">&lt;link rel="stylesheet" type="text/css" href="//cdn.moot.it/1/moot.css"&gt;</span>
  1754. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-6"></a><span class="s2">&lt;meta name="viewport" content="width=device-width"&gt;</span>
  1755. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-7"></a><span class="s2">&lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;</span>
  1756. <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-8"></a><span class="s2">"""</span>
  1757. </pre></aside><aside class="admonition admonition-facebook-support"><p class="admonition-title">Facebook Support</p>
  1758. <p>You need jQuery, but not because Facebook wants it (see Issue
  1759. #639).</p>
  1760. </aside><aside class="admonition admonition-utterances-support"><p class="admonition-title">Utterances Support</p>
  1761. <p>You can copy the configuration options from the <a class="reference external" href="https://utteranc.es">Utterances setup page</a> into <code class="docutils literal"><span class="pre">GLOBAL_CONTEXT['utterances_config']</span></code>,
  1762. except for <code class="docutils literal">repo</code>, which should be set as <code class="docutils literal">COMMENT_SYSTEM_ID</code>. Note
  1763. that the either <code class="docutils literal"><span class="pre">issue-term</span></code> or <code class="docutils literal"><span class="pre">issue-number</span></code> must be provided. All
  1764. other Utterances configuration options are optional.</p>
  1765. </aside></section><section id="images-and-galleries"><h2><a class="toc-backref" href="handbook.html#toc-entry-63" role="doc-backlink">Images and Galleries</a></h2>
  1766. <p>To create an image gallery, all you have to do is add a folder inside <code class="docutils literal">galleries</code>,
  1767. and put images there. Nikola will take care of creating thumbnails, index page, etc.</p>
  1768. <p>If you click on images on a gallery, or on images with links in post, you will
  1769. see a bigger image, thanks to the excellent <a class="reference external" href="https://feimosi.github.io/baguetteBox.js/">baguetteBox</a>. If don’t want this behavior, add an
  1770. <code class="docutils literal">.islink</code> class to your link.</p>
  1771. <p>The gallery pages are generated using the <code class="docutils literal">gallery.tmpl</code> template, and you can
  1772. customize it there (you could switch to another lightbox instead of baguetteBox, change
  1773. its settings, change the layout, etc.).</p>
  1774. <p>Images in galleries may be provided with captions and given a specific
  1775. ordering, by creating a file in the gallery directory called <code class="docutils literal">metadata.yml</code>.
  1776. This YAML file should contain a <code class="docutils literal">name</code> field for each image in the gallery
  1777. for which you wish to provide either a caption or specific ordering. You can also
  1778. create localized versions (<code class="docutils literal">metadata.xx.yml</code>).</p>
  1779. <p>Only one <code class="docutils literal">metadata.yml</code> is needed per gallery. Here is an example, showing names,
  1780. captions and ordering. <code class="docutils literal">caption</code> and <code class="docutils literal">order</code> are given special treatment,
  1781. anything else is available to templates, as keys of <code class="docutils literal">photo_array</code> images.</p>
  1782. <pre class="code yaml"><a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-1"></a><span class="nn">---</span>
  1783. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-2"></a><span class="nt">name</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">ready-for-the-acid-wash.jpg</span>
  1784. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-3"></a><span class="nn">---</span>
  1785. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-4"></a><span class="nt">name</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">almost-full.jpg</span>
  1786. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-5"></a><span class="nt">caption</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">The pool is now almost full</span>
  1787. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-6"></a><span class="nn">---</span>
  1788. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-7"></a><span class="nt">name</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">jumping-in.jpg</span>
  1789. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-8"></a><span class="nt">caption</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">We're enjoying the new pool already</span>
  1790. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-9"></a><span class="nt">order</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">4</span>
  1791. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-10"></a><span class="nn">---</span>
  1792. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-11"></a><span class="nt">name</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">waterline-tiles.jpg</span>
  1793. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-12"></a><span class="nt">order</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">2</span>
  1794. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-13"></a><span class="nt">custom</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">metadata is supported</span>
  1795. <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-14"></a><span class="nn">---</span>
  1796. </pre>
  1797. <p>Images to be used in normal posts can be placed in the <code class="docutils literal">images</code> folder. These
  1798. images will be processed and have thumbnails created just as for galleries, but will
  1799. then be copied directly to the corresponding path in the <code class="docutils literal">output</code> directory, so you
  1800. can reference it from whatever page you like, most easily using the <code class="docutils literal">thumbnail</code>
  1801. reST extension. If you don't want thumbnails, just use the <code class="docutils literal">files</code> folder instead.</p>
  1802. <p>The <code class="docutils literal">conf.py</code> options affecting images and gallery pages are these:</p>
  1803. <pre class="code python"><a name="rest_code_8805d8ef5320446780b0942becf47084-1"></a><span class="c1"># One or more folders containing galleries. The format is a dictionary of</span>
  1804. <a name="rest_code_8805d8ef5320446780b0942becf47084-2"></a><span class="c1"># {"source": "relative_destination"}, where galleries are looked for in</span>
  1805. <a name="rest_code_8805d8ef5320446780b0942becf47084-3"></a><span class="c1"># "source/" and the results will be located in</span>
  1806. <a name="rest_code_8805d8ef5320446780b0942becf47084-4"></a><span class="c1"># "OUTPUT_PATH/relative_destination/gallery_name"</span>
  1807. <a name="rest_code_8805d8ef5320446780b0942becf47084-5"></a><span class="c1"># Default is:</span>
  1808. <a name="rest_code_8805d8ef5320446780b0942becf47084-6"></a><span class="n">GALLERY_FOLDERS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"galleries"</span><span class="p">:</span> <span class="s2">"galleries"</span><span class="p">}</span>
  1809. <a name="rest_code_8805d8ef5320446780b0942becf47084-7"></a><span class="c1"># More gallery options:</span>
  1810. <a name="rest_code_8805d8ef5320446780b0942becf47084-8"></a><span class="n">THUMBNAIL_SIZE</span> <span class="o">=</span> <span class="mi">180</span>
  1811. <a name="rest_code_8805d8ef5320446780b0942becf47084-9"></a><span class="n">MAX_IMAGE_SIZE</span> <span class="o">=</span> <span class="mi">1280</span>
  1812. <a name="rest_code_8805d8ef5320446780b0942becf47084-10"></a><span class="n">USE_FILENAME_AS_TITLE</span> <span class="o">=</span> <span class="kc">True</span>
  1813. <a name="rest_code_8805d8ef5320446780b0942becf47084-11"></a><span class="n">EXTRA_IMAGE_EXTENSIONS</span> <span class="o">=</span> <span class="p">[]</span>
  1814. <a name="rest_code_8805d8ef5320446780b0942becf47084-12"></a>
  1815. <a name="rest_code_8805d8ef5320446780b0942becf47084-13"></a><span class="c1"># Use a thumbnail (defined by ".. previewimage:" in the gallery's index) in</span>
  1816. <a name="rest_code_8805d8ef5320446780b0942becf47084-14"></a><span class="c1"># list of galleries for each gallery</span>
  1817. <a name="rest_code_8805d8ef5320446780b0942becf47084-15"></a><span class="n">GALLERIES_USE_THUMBNAIL</span> <span class="o">=</span> <span class="kc">False</span>
  1818. <a name="rest_code_8805d8ef5320446780b0942becf47084-16"></a>
  1819. <a name="rest_code_8805d8ef5320446780b0942becf47084-17"></a><span class="c1"># Image to use as thumbnail for those galleries that don't have one</span>
  1820. <a name="rest_code_8805d8ef5320446780b0942becf47084-18"></a><span class="c1"># None: show a grey square</span>
  1821. <a name="rest_code_8805d8ef5320446780b0942becf47084-19"></a><span class="c1"># '/url/to/file': show the image in that url</span>
  1822. <a name="rest_code_8805d8ef5320446780b0942becf47084-20"></a><span class="n">GALLERIES_DEFAULT_THUMBNAIL</span> <span class="o">=</span> <span class="kc">None</span>
  1823. <a name="rest_code_8805d8ef5320446780b0942becf47084-21"></a>
  1824. <a name="rest_code_8805d8ef5320446780b0942becf47084-22"></a><span class="c1"># If set to False, it will sort by filename instead. Defaults to True</span>
  1825. <a name="rest_code_8805d8ef5320446780b0942becf47084-23"></a><span class="n">GALLERY_SORT_BY_DATE</span> <span class="o">=</span> <span class="kc">True</span>
  1826. <a name="rest_code_8805d8ef5320446780b0942becf47084-24"></a>
  1827. <a name="rest_code_8805d8ef5320446780b0942becf47084-25"></a><span class="c1"># Folders containing images to be used in normal posts or pages.</span>
  1828. <a name="rest_code_8805d8ef5320446780b0942becf47084-26"></a><span class="c1"># IMAGE_FOLDERS is a dictionary of the form {"source": "destination"},</span>
  1829. <a name="rest_code_8805d8ef5320446780b0942becf47084-27"></a><span class="c1"># where "source" is the folder containing the images to be published, and</span>
  1830. <a name="rest_code_8805d8ef5320446780b0942becf47084-28"></a><span class="c1"># "destination" is the folder under OUTPUT_PATH containing the images copied</span>
  1831. <a name="rest_code_8805d8ef5320446780b0942becf47084-29"></a><span class="c1"># to the site. Thumbnail images will be created there as well.</span>
  1832. <a name="rest_code_8805d8ef5320446780b0942becf47084-30"></a><span class="n">IMAGE_FOLDERS</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'images'</span><span class="p">:</span> <span class="s1">'images'</span><span class="p">}</span>
  1833. <a name="rest_code_8805d8ef5320446780b0942becf47084-31"></a>
  1834. <a name="rest_code_8805d8ef5320446780b0942becf47084-32"></a><span class="c1"># Images will be scaled down according to IMAGE_THUMBNAIL_SIZE and MAX_IMAGE_SIZE</span>
  1835. <a name="rest_code_8805d8ef5320446780b0942becf47084-33"></a><span class="c1"># options, but will have to be referenced manually to be visible on the site</span>
  1836. <a name="rest_code_8805d8ef5320446780b0942becf47084-34"></a><span class="c1"># (the thumbnail has ``.thumbnail`` added before the file extension by default,</span>
  1837. <a name="rest_code_8805d8ef5320446780b0942becf47084-35"></a><span class="c1"># but a different naming template can be configured with IMAGE_THUMBNAIL_FORMAT).</span>
  1838. <a name="rest_code_8805d8ef5320446780b0942becf47084-36"></a><span class="n">IMAGE_THUMBNAIL_SIZE</span> <span class="o">=</span> <span class="mi">400</span>
  1839. <a name="rest_code_8805d8ef5320446780b0942becf47084-37"></a><span class="n">IMAGE_THUMBNAIL_FORMAT</span> <span class="o">=</span> <span class="s1">'</span><span class="si">{name}</span><span class="s1">.thumbnail</span><span class="si">{ext}</span><span class="s1">'</span>
  1840. </pre>
  1841. <p>If you add a reST file in <code class="docutils literal">galleries/gallery_name/index.txt</code> its contents will be
  1842. converted to HTML and inserted above the images in the gallery page. The
  1843. format is the same as for posts. You can use the <code class="docutils literal">title</code>, <code class="docutils literal">previewimage</code>, and
  1844. <code class="docutils literal">status</code> metadata fields to change how the gallery is shown.</p>
  1845. <p>If the <code class="docutils literal">status</code> is <code class="docutils literal">private</code>, <code class="docutils literal">draft</code>, or <code class="docutils literal">publish_later</code>, the
  1846. gallery will not appear in the index, the RSS feeds, nor in the sitemap.</p>
  1847. <p>If you add some image filenames in <code class="docutils literal">galleries/gallery_name/exclude.meta</code>, they
  1848. will be excluded in the gallery page.</p>
  1849. <p>If <code class="docutils literal">USE_FILENAME_AS_TITLE</code> is True the filename (parsed as a readable string)
  1850. is used as the photo caption. If the filename starts with a number, it will
  1851. be stripped. For example <code class="docutils literal">03_an_amazing_sunrise.jpg</code> will be render as <em>An amazing sunrise</em>.</p>
  1852. <p>Here is a <a class="reference external" href="../galleries/demo">demo gallery</a> of historic, public domain Nikola
  1853. Tesla pictures taken from <a class="reference external" href="https://kerryr.net/pioneers/gallery/tesla.htm">this site</a>.</p>
  1854. <section id="embedding-images"><h3><a class="toc-backref" href="handbook.html#toc-entry-64" role="doc-backlink">Embedding Images</a></h3>
  1855. <p>Assuming that you have your pictures stored in a folder called <code class="docutils literal">images</code> (as configured above),
  1856. you can embed the same in your posts with the following reST directive:</p>
  1857. <pre class="code rest"><a name="rest_code_904428bd98e347cc9f0946216fcea184-1"></a><span class="p">..</span> <span class="ow">image</span><span class="p">::</span> /images/tesla.jpg
  1858. </pre>
  1859. <p>Which is equivalent to the following HTML code:</p>
  1860. <pre class="code html"><a name="rest_code_0fb93ef519964ad4a6c5c27cd7c444b6-1"></a><span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"/images/tesla.jpg"</span><span class="p">&gt;</span>
  1861. </pre>
  1862. <p>Please take note of the leading forward-slash <code class="docutils literal">/</code> which refers to the root
  1863. output directory. (Make sure to use this even if you’re not deploying to
  1864. web server root.)</p>
  1865. <p>You can also use thumbnails with the <code class="docutils literal">.. thumbnail::</code> reST directive. For
  1866. more details, and equivalent HTML code, see <a class="reference internal" href="handbook.html#thumbnails">Thumbnails</a>.</p>
  1867. </section></section><section id="handling-exif-data"><h2><a class="toc-backref" href="handbook.html#toc-entry-65" role="doc-backlink">Handling EXIF Data</a></h2>
  1868. <p>Your images contain a certain amount of extra data besides the image itself,
  1869. called the <a class="reference external" href="https://en.wikipedia.org/wiki/Exchangeable_image_file_format">EXIF metadata.</a>
  1870. It contains information about the camera you used to take the picture, when it was taken,
  1871. and maybe even the location where it was taken.</p>
  1872. <p>This is both useful, because you can use it in some apps to locate all the pictures taken
  1873. in a certain place, or with a certain camera, but also, since the pictures Nikola
  1874. publishes are visible to anyone on the Internet, a privacy risk worth considering
  1875. (Imagine if you post pictures taken at home with GPS info, you are publishing your
  1876. home address!)</p>
  1877. <p>Nikola has some support for managing it, so let's go through a few scenarios to
  1878. see which one you prefer.</p>
  1879. <section id="strip-all-exif-data"><h3><a class="toc-backref" href="handbook.html#toc-entry-66" role="doc-backlink">Strip all EXIF data</a></h3>
  1880. <p>Do this if you want to be absolutely sure that no sensitive information should ever leak:</p>
  1881. <pre class="code python"><a name="rest_code_6a59dc109c2349f9b3f26058211d2f38-1"></a><span class="n">PRESERVE_EXIF_DATA</span> <span class="o">=</span> <span class="kc">False</span>
  1882. <a name="rest_code_6a59dc109c2349f9b3f26058211d2f38-2"></a><span class="n">EXIF_WHITELIST</span> <span class="o">=</span> <span class="p">{}</span>
  1883. </pre></section><section id="preserve-all-exif-data"><h3><a class="toc-backref" href="handbook.html#toc-entry-67" role="doc-backlink">Preserve all EXIF data</a></h3>
  1884. <p>Do this if you really don't mind people knowing where pictures were taken, or camera settings:</p>
  1885. <pre class="code python"><a name="rest_code_d1897f1f3c2348f89ea212ec4b07ee6b-1"></a><span class="n">PRESERVE_EXIF_DATA</span> <span class="o">=</span> <span class="kc">True</span>
  1886. <a name="rest_code_d1897f1f3c2348f89ea212ec4b07ee6b-2"></a><span class="n">EXIF_WHITELIST</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'*'</span><span class="p">:</span> <span class="s1">'*'</span><span class="p">}</span>
  1887. </pre></section><section id="preserve-some-exif-data"><h3><a class="toc-backref" href="handbook.html#toc-entry-68" role="doc-backlink">Preserve some EXIF data</a></h3>
  1888. <p>Do this if you really know what you are doing. EXIF data comes separated in a few IFD blocks.
  1889. The most common ones are:</p>
  1890. <dl class="simple">
  1891. <dt>0th</dt>
  1892. <dd>
  1893. <p>Information about the image itself</p>
  1894. </dd>
  1895. <dt>Exif</dt>
  1896. <dd>
  1897. <p>Information about the camera and the image</p>
  1898. </dd>
  1899. <dt>1st</dt>
  1900. <dd>
  1901. <p>Information about embedded thumbnails (usually nothing)</p>
  1902. </dd>
  1903. <dt>thumbnail</dt>
  1904. <dd>
  1905. <p>An embedded thumbnail, in JPEG format (usually nothing)</p>
  1906. </dd>
  1907. <dt>GPS</dt>
  1908. <dd>
  1909. <p>Geolocation information about the image</p>
  1910. </dd>
  1911. <dt>Interop</dt>
  1912. <dd>
  1913. <p>Not too interesting at this point.</p>
  1914. </dd>
  1915. </dl>
  1916. <p>Each IFD in turn contains a number of tags. For example, 0th contains a ImageWidth tag.
  1917. You can tell Nikola exactly which IFDs to keep, and within each IFD, which tags to keep,
  1918. using the EXIF_WHITELIST option.</p>
  1919. <p>Let's see an example:</p>
  1920. <pre class="code python"><a name="rest_code_074d6b8c00034aa88655763ba6018095-1"></a><span class="n">PRESERVE_EXIF_DATA</span> <span class="o">=</span> <span class="kc">True</span>
  1921. <a name="rest_code_074d6b8c00034aa88655763ba6018095-2"></a><span class="n">EXIF_WHITELIST</span> <span class="o">=</span> <span class="p">{</span>
  1922. <a name="rest_code_074d6b8c00034aa88655763ba6018095-3"></a> <span class="s2">"0th"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Orientation"</span><span class="p">,</span> <span class="s2">"ImageWidth"</span><span class="p">,</span> <span class="s2">"ImageLength"</span><span class="p">],</span>
  1923. <a name="rest_code_074d6b8c00034aa88655763ba6018095-4"></a> <span class="s2">"Interop"</span><span class="p">:</span> <span class="s2">"*"</span><span class="p">,</span>
  1924. <a name="rest_code_074d6b8c00034aa88655763ba6018095-5"></a><span class="p">}</span>
  1925. </pre>
  1926. <p>So, we preserve EXIF data, and the whitelisted IFDs are "0th" and "Interop". That means
  1927. GPS, for example, will be totally deleted.</p>
  1928. <p>Then, for the Interop IFD, we keep everything, and for the 0th IFD we only keep three tags,
  1929. listed there.</p>
  1930. <p>There is a huge number of EXIF tags, described in <a class="reference external" href="http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf">the standard</a></p>
  1931. </section></section><section id="handling-icc-profiles"><h2><a class="toc-backref" href="handbook.html#toc-entry-69" role="doc-backlink">Handling ICC Profiles</a></h2>
  1932. <p>Your images may contain <a class="reference external" href="https://en.wikipedia.org/wiki/ICC_profile">ICC profiles.</a> These describe the color space in which the images were created or captured.</p>
  1933. <p>Most desktop web browsers can use embedded ICC profiles to display images accurately. As of early 2018 few mobile browsers consider ICC profiles when displaying images. A notable exception is Safari on iOS.</p>
  1934. <p>By default Nikola strips out ICC profiles when preparing images for your posts and galleries. If you want Nikola to preserve ICC profiles, add this in your <code class="docutils literal">conf.py</code>:</p>
  1935. <pre class="code python"><a name="rest_code_e6eaf766378841bbbc860d3b11122679-1"></a><span class="n">PRESERVE_ICC_PROFILES</span> <span class="o">=</span> <span class="kc">True</span>
  1936. </pre>
  1937. <p>You may wish to do this if, for example, your site contains JPEG images that use a wide-gamut profile such as "Display P3".</p>
  1938. </section><section id="post-processing-filters"><h2><a class="toc-backref" href="handbook.html#toc-entry-70" role="doc-backlink">Post Processing Filters</a></h2>
  1939. <p>You can apply post processing to the files in your site, in order to optimize them
  1940. or change them in arbitrary ways. For example, you may want to compress all CSS
  1941. and JS files using yui-compressor.</p>
  1942. <p>To do that, you can use the provided helper adding this in your <code class="docutils literal">conf.py</code>:</p>
  1943. <pre class="code python"><a name="rest_code_42fbfa656d7046b1b4212f89ab8de86f-1"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
  1944. <a name="rest_code_42fbfa656d7046b1b4212f89ab8de86f-2"></a> <span class="s2">".css"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"filters.yui_compressor"</span><span class="p">],</span>
  1945. <a name="rest_code_42fbfa656d7046b1b4212f89ab8de86f-3"></a> <span class="s2">".js"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"filters.yui_compressor"</span><span class="p">],</span>
  1946. <a name="rest_code_42fbfa656d7046b1b4212f89ab8de86f-4"></a><span class="p">}</span>
  1947. </pre>
  1948. <p>Where <code class="docutils literal">"filters.yui_compressor"</code> points to a helper function provided by Nikola in the
  1949. <code class="docutils literal">filters</code> module. You can replace that with strings describing command lines, or
  1950. arbitrary python functions.</p>
  1951. <p>If there's any specific thing you expect to be generally useful as a filter, contact
  1952. me and I will add it to the filters library so that more people use it.</p>
  1953. <p>The currently available filters are:</p>
  1954. <aside class="sidebar"><p class="sidebar-title">Creating your own filters</p>
  1955. <p>You can use any program name that works in place as a filter, like <code class="docutils literal">sed <span class="pre">-i</span></code>
  1956. and you can use arbitrary Python functions as filters, too.</p>
  1957. <p>If your program doesn't run in-place, then you can use Nikola's <code class="docutils literal">runinplace</code> function (from the <code class="docutils literal">filters</code> module).
  1958. For example, this is how the yui_compressor filter is implemented:</p>
  1959. <pre class="code python"><a name="rest_code_24d77c8a82ff4e1893763213b8495827-1"></a><span class="kn">from</span> <span class="nn">nikola.filters</span> <span class="kn">import</span> <span class="n">runinplace</span>
  1960. <a name="rest_code_24d77c8a82ff4e1893763213b8495827-2"></a><span class="k">def</span> <span class="nf">yui_compressor</span><span class="p">(</span><span class="n">infile</span><span class="p">):</span>
  1961. <a name="rest_code_24d77c8a82ff4e1893763213b8495827-3"></a> <span class="k">return</span> <span class="n">runinplace</span><span class="p">(</span><span class="sa">r</span><span class="s1">'yui-compressor --nomunge %1 -o %2'</span><span class="p">,</span> <span class="n">infile</span><span class="p">)</span>
  1962. </pre>
  1963. <p>You can turn any function into a filter using <code class="docutils literal">apply_to_text_file</code> (for
  1964. text files to be read in UTF-8) and <code class="docutils literal">apply_to_binary_file</code> (for files to
  1965. be read in binary mode).</p>
  1966. <p>As a silly example, this would make everything uppercase and totally break
  1967. your website:</p>
  1968. <pre class="code python"><a name="rest_code_53c8543032bb404882fc332baf04c954-1"></a><span class="kn">import</span> <span class="nn">string</span>
  1969. <a name="rest_code_53c8543032bb404882fc332baf04c954-2"></a><span class="kn">from</span> <span class="nn">nikola.filters</span> <span class="kn">import</span> <span class="n">apply_to_text_file</span>
  1970. <a name="rest_code_53c8543032bb404882fc332baf04c954-3"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
  1971. <a name="rest_code_53c8543032bb404882fc332baf04c954-4"></a> <span class="s2">".html"</span><span class="p">:</span> <span class="p">[</span><span class="n">apply_to_text_file</span><span class="p">(</span><span class="n">string</span><span class="o">.</span><span class="n">upper</span><span class="p">)]</span>
  1972. <a name="rest_code_53c8543032bb404882fc332baf04c954-5"></a><span class="p">}</span>
  1973. </pre></aside><dl>
  1974. <dt>filters.html_tidy_nowrap</dt>
  1975. <dd>
  1976. <p>Prettify HTML 5 documents with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
  1977. </dd>
  1978. <dt>filters.html_tidy_wrap</dt>
  1979. <dd>
  1980. <p>Prettify HTML 5 documents wrapped at 80 characters with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
  1981. </dd>
  1982. <dt>filters.html_tidy_wrap_attr</dt>
  1983. <dd>
  1984. <p>Prettify HTML 5 documents and wrap lines and attributes with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
  1985. </dd>
  1986. <dt>filters.html_tidy_mini</dt>
  1987. <dd>
  1988. <p>Minify HTML 5 into smaller documents with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
  1989. </dd>
  1990. <dt>filters.html_tidy_withconfig</dt>
  1991. <dd>
  1992. <p>Run <a class="reference external" href="https://www.html-tidy.org/">tidy5</a> with <code class="docutils literal">tidy5.conf</code> as the config file (supplied by user)</p>
  1993. </dd>
  1994. <dt>filters.html5lib_minify</dt>
  1995. <dd>
  1996. <p>Minify HTML5 using html5lib_minify</p>
  1997. </dd>
  1998. <dt>filters.html5lib_xmllike</dt>
  1999. <dd>
  2000. <p>Format using html5lib</p>
  2001. </dd>
  2002. <dt>filters.typogrify</dt>
  2003. <dd>
  2004. <p>Improve typography using <a class="reference external" href="https://github.com/mintchaos/typogrify">typogrify</a></p>
  2005. </dd>
  2006. <dt>filters.typogrify_sans_widont</dt>
  2007. <dd>
  2008. <p>Same as typogrify without the widont filter</p>
  2009. </dd>
  2010. <dt>filters.typogrify_custom</dt>
  2011. <dd>
  2012. <p>Run typogrify with a custom set of filters or ignored HTML elements. Takes one or
  2013. both of the arguments <code class="docutils literal">typogrify_filters</code> or <code class="docutils literal">ignore_tags</code>. <code class="docutils literal">typogrify_filters</code>
  2014. must be a list of typogrify filter callables to run. <code class="docutils literal">ignore_tags</code> must be a list
  2015. of strings specifying HTML tags, CSS classes (prefixed with <code class="docutils literal">.</code>), tag <code class="docutils literal">id</code> names
  2016. (prefixed with <code class="docutils literal">#</code>), or a tag and a class or id. The following code should be
  2017. placed in <code class="docutils literal">conf.py</code>.</p>
  2018. <pre class="code python"><a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-1"></a><span class="kn">from</span> <span class="nn">nikola.filters</span> <span class="kn">import</span> <span class="n">typogrify_custom</span>
  2019. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-2"></a><span class="kn">import</span> <span class="nn">functools</span>
  2020. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-3"></a><span class="c1"># This filter will ignore HTML elements with the CSS class "typo-ignore"</span>
  2021. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-4"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
  2022. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-5"></a> <span class="s2">".html"</span><span class="p">:</span> <span class="p">[</span><span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span><span class="n">typogrify_custom</span><span class="p">,</span> <span class="n">ignore_tags</span><span class="o">=</span><span class="p">[</span><span class="s2">".typo-ignore"</span><span class="p">])]</span>
  2023. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-6"></a><span class="p">}</span>
  2024. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-7"></a><span class="c1"># Alternatively, to specify ``typogrify_filters``</span>
  2025. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-8"></a><span class="kn">import</span> <span class="nn">typogrify.filters</span> <span class="k">as</span> <span class="nn">typo</span>
  2026. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-9"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
  2027. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-10"></a> <span class="s2">".html"</span><span class="p">:</span> <span class="p">[</span><span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span><span class="n">typogrify_custom</span><span class="p">,</span> <span class="n">typogrify_filters</span><span class="o">=</span><span class="p">[</span><span class="n">typo</span><span class="o">.</span><span class="n">amp</span><span class="p">])]</span>
  2028. <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-11"></a><span class="p">}</span>
  2029. </pre>
  2030. <p>The default value for <code class="docutils literal">typogrify_filters</code> is
  2031. <code class="docutils literal">[typo.amp, typo.widont, typo.smartypants, typo.caps, typo.initial_quotes]</code> and the
  2032. default value for <code class="docutils literal">ignore_tags</code> is <code class="docutils literal">["title", ".math"]</code>. If <code class="docutils literal">ignore_tags</code> is
  2033. specified, the default tags will be appended to the supplied list. See the
  2034. <a class="reference external" href="https://github.com/mintchaos/typogrify/blob/master/typogrify/filters.py#L8-L14">documentation</a>
  2035. for the <code class="docutils literal">process_ignores</code> function in typogrify.</p>
  2036. </dd>
  2037. <dt>filters.minify_lines</dt>
  2038. <dd>
  2039. <p><strong>THIS FILTER HAS BEEN TURNED INTO A NOOP</strong> and currently does nothing.</p>
  2040. </dd>
  2041. <dt>filters.normalize_html</dt>
  2042. <dd>
  2043. <p>Pass HTML through LXML to normalize it. For example, it will resolve <code class="docutils literal">&amp;quot;</code> to actual
  2044. quotes. Usually not needed.</p>
  2045. </dd>
  2046. <dt>filters.yui_compressor</dt>
  2047. <dd>
  2048. <p>Compress CSS/JavaScript using <a class="reference external" href="https://yui.github.io/yuicompressor/">YUI compressor</a></p>
  2049. </dd>
  2050. <dt>filters.closure_compiler</dt>
  2051. <dd>
  2052. <p>Compile, compress, and optimize JavaScript <a class="reference external" href="https://developers.google.com/closure/compiler/">Google Closure Compiler</a></p>
  2053. </dd>
  2054. <dt>filters.optipng</dt>
  2055. <dd>
  2056. <p>Compress PNG files using <a class="reference external" href="http://optipng.sourceforge.net/">optipng</a></p>
  2057. </dd>
  2058. <dt>filters.jpegoptim</dt>
  2059. <dd>
  2060. <p>Compress JPEG files using <a class="reference external" href="https://www.kokkonen.net/tjko/projects.html">jpegoptim</a></p>
  2061. </dd>
  2062. <dt>filters.cssminify</dt>
  2063. <dd>
  2064. <p>Minify CSS using <a class="reference external" href="https://cssminifier.com/">https://cssminifier.com/</a> (requires Internet access)</p>
  2065. </dd>
  2066. <dt>filters.jsminify</dt>
  2067. <dd>
  2068. <p>Minify JS using <a class="reference external" href="https://javascript-minifier.com/">https://javascript-minifier.com/</a> (requires Internet access)</p>
  2069. </dd>
  2070. <dt>filters.jsonminify</dt>
  2071. <dd>
  2072. <p>Minify JSON files (strip whitespace and use minimal separators).</p>
  2073. </dd>
  2074. <dt>filters.xmlminify</dt>
  2075. <dd>
  2076. <p>Minify XML files. Suitable for Nikola’s sitemaps and Atom feeds.</p>
  2077. </dd>
  2078. <dt>filters.add_header_permalinks</dt>
  2079. <dd>
  2080. <p>Add links next to every header, Sphinx-style. You will need to add styling for the <cite>headerlink</cite> class,
  2081. in <cite>custom.css</cite>, for example:</p>
  2082. <pre class="code css"><a name="rest_code_23a0b8e4e225420e91637d0a55452b18-1"></a><span class="c">/* Header permalinks */</span>
  2083. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-2"></a><span class="nt">h1</span><span class="p">:</span><span class="nd">hover</span> <span class="p">.</span><span class="nc">headerlink</span><span class="o">,</span> <span class="nt">h2</span><span class="p">:</span><span class="nd">hover</span> <span class="p">.</span><span class="nc">headerlink</span><span class="o">,</span>
  2084. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-3"></a><span class="nt">h3</span><span class="p">:</span><span class="nd">hover</span> <span class="p">.</span><span class="nc">headerlink</span><span class="o">,</span> <span class="nt">h4</span><span class="p">:</span><span class="nd">hover</span> <span class="p">.</span><span class="nc">headerlink</span><span class="o">,</span>
  2085. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-4"></a><span class="nt">h5</span><span class="p">:</span><span class="nd">hover</span> <span class="p">.</span><span class="nc">headerlink</span><span class="o">,</span> <span class="nt">h6</span><span class="p">:</span><span class="nd">hover</span> <span class="p">.</span><span class="nc">headerlink</span> <span class="p">{</span>
  2086. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-5"></a> <span class="k">display</span><span class="p">:</span> <span class="kc">inline</span><span class="p">;</span>
  2087. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-6"></a><span class="p">}</span>
  2088. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-7"></a>
  2089. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-8"></a><span class="p">.</span><span class="nc">headerlink</span> <span class="p">{</span>
  2090. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-9"></a> <span class="k">display</span><span class="p">:</span> <span class="kc">none</span><span class="p">;</span>
  2091. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-10"></a> <span class="k">color</span><span class="p">:</span> <span class="mh">#ddd</span><span class="p">;</span>
  2092. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-11"></a> <span class="k">margin-left</span><span class="p">:</span> <span class="mf">0.2</span><span class="kt">em</span><span class="p">;</span>
  2093. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-12"></a> <span class="k">padding</span><span class="p">:</span> <span class="mi">0</span> <span class="mf">0.2</span><span class="kt">em</span><span class="p">;</span>
  2094. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-13"></a><span class="p">}</span>
  2095. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-14"></a>
  2096. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-15"></a><span class="p">.</span><span class="nc">headerlink</span><span class="p">:</span><span class="nd">hover</span> <span class="p">{</span>
  2097. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-16"></a> <span class="k">opacity</span><span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
  2098. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-17"></a> <span class="k">background</span><span class="p">:</span> <span class="mh">#ddd</span><span class="p">;</span>
  2099. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-18"></a> <span class="k">color</span><span class="p">:</span> <span class="mh">#000</span><span class="p">;</span>
  2100. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-19"></a> <span class="k">text-decoration</span><span class="p">:</span> <span class="kc">none</span><span class="p">;</span>
  2101. <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-20"></a><span class="p">}</span>
  2102. </pre>
  2103. <p>Additionally, you can provide a custom list of XPath expressions which should be used for finding headers (<code class="docutils literal">{hx}</code> is replaced by headers h1 through h6).
  2104. This is required if you use a custom theme that does not use <code class="docutils literal"><span class="pre">"e-content</span> <span class="pre">entry-content"</span></code> as a class for post and page contents.</p>
  2105. <pre class="code python"><a name="rest_code_aee967f647e14195b882cad72e443193-1"></a><span class="c1"># Default value:</span>
  2106. <a name="rest_code_aee967f647e14195b882cad72e443193-2"></a><span class="n">HEADER_PERMALINKS_XPATH_LIST</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'*//div[@class="e-content entry-content"]//</span><span class="si">{hx}</span><span class="s1">'</span><span class="p">]</span>
  2107. <a name="rest_code_aee967f647e14195b882cad72e443193-3"></a><span class="c1"># Include *every* header (not recommended):</span>
  2108. <a name="rest_code_aee967f647e14195b882cad72e443193-4"></a><span class="c1"># HEADER_PERMALINKS_XPATH_LIST = ['*//{hx}']</span>
  2109. </pre>
  2110. </dd>
  2111. <dt>filters.deduplicate_ids</dt>
  2112. <dd>
  2113. <p>Prevent duplicated IDs in HTML output. An incrementing counter is added to
  2114. offending IDs. If used alongside <code class="docutils literal">add_header_permalinks</code>, it will fix
  2115. those links (it must run <strong>after</strong> that filter)</p>
  2116. <p>IDs are numbered from the bottom up, which is useful for indexes (updates
  2117. appear at the top). There are exceptions, which may be configured using
  2118. <code class="docutils literal">DEDUPLICATE_IDS_TOP_CLASSES</code> — if any of those classes appears sin the
  2119. document, the IDs are rewritten top-down, which is useful for posts/pages
  2120. (updates appear at the bottom).</p>
  2121. <p>Note that in rare cases, permalinks might not always be <em>permanent</em> in case
  2122. of edits.</p>
  2123. <pre class="code python"><a name="rest_code_e4306ecfa4134588874b554eeb9aa7f1-1"></a><span class="n">DEDUPLICATE_IDS_TOP_CLASSES</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'postpage'</span><span class="p">,</span> <span class="s1">'storypage'</span><span class="p">)</span>
  2124. </pre>
  2125. <p>You can also use a file blacklist (<code class="docutils literal">HEADER_PERMALINKS_FILE_BLACKLIST</code>),
  2126. useful for some index pages. Paths include the output directory (eg.
  2127. <code class="docutils literal">output/index.html</code>)</p>
  2128. </dd>
  2129. </dl>
  2130. <p>You can apply filters to specific posts or pages by using the <code class="docutils literal">filters</code> metadata field:</p>
  2131. <pre class="code restructuredtext"><a name="rest_code_a5571e38ee544cccaa8110629a6778fb-1"></a><span class="cp">.. filters: filters.html_tidy_nowrap, "sed s/foo/bar %s"</span>
  2132. </pre>
  2133. <p>Please note that applying custom filters (not those provided via Nikola's filter module)
  2134. via metadata only works for filters implemented via external programs like in that <cite>sed</cite> example.</p>
  2135. </section><section id="optimizing-your-website"><h2><a class="toc-backref" href="handbook.html#toc-entry-71" role="doc-backlink">Optimizing Your Website</a></h2>
  2136. <p>One of the main goals of Nikola is to make your site fast and light. So here are a few
  2137. tips we have found when setting up Nikola with Apache. If you have more, or
  2138. different ones, or about other web servers, please share!</p>
  2139. <ol class="arabic">
  2140. <li><p>Use a speed testing tool. I used Yahoo's YSlow but you can use any of them, and
  2141. it's probably a good idea to use more than one.</p></li>
  2142. <li>
  2143. <p>Enable compression in Apache:</p>
  2144. <pre class="code apache"><a name="rest_code_5264f69fd10443d7b15ff2e58cba557b-1"></a><span class="nb">AddOutputFilterByType</span> DEFLATE text/html text/plain text/xml text/css text/javascript
  2145. </pre>
  2146. </li>
  2147. <li>
  2148. <p>If even after you did the previous step the CSS files are not sent compressed:</p>
  2149. <pre class="code apache"><a name="rest_code_35580c9bfd29414aa75d002cc8b6dd19-1"></a><span class="nb">AddType</span> text/css .css
  2150. </pre>
  2151. </li>
  2152. <li><p>Optionally you can create static compressed copies and save some CPU on your server
  2153. with the GZIP_FILES option in Nikola.</p></li>
  2154. <li><p>The bundles Nikola plugin can drastically decrease the number of CSS and JS files your site fetches.</p></li>
  2155. <li><p>Through the filters feature, you can run your files through arbitrary commands, so that images
  2156. are recompressed, JavaScript is minimized, etc.</p></li>
  2157. <li><p>The USE_CDN option offloads standard JavaScript and CSS files to a CDN so they are not
  2158. downloaded from your server.</p></li>
  2159. </ol></section><section id="math"><h2><a class="toc-backref" href="handbook.html#toc-entry-72" role="doc-backlink">Math</a></h2>
  2160. <p>Nikola supports math input via MathJax (by default) or KaTeX. It is activated
  2161. via the math roles and directives of reStructuredText and the usual LaTeX
  2162. delimiters for other input formats.</p>
  2163. <section id="configuration-1"><h3><a class="toc-backref" href="handbook.html#toc-entry-73" role="doc-backlink">Configuration</a></h3>
  2164. <p>Nikola uses MathJax by default. If you want to use KaTeX (faster and prettier,
  2165. but may not support every feature yet), set <code class="docutils literal">USE_KATEX = True</code> in
  2166. <code class="docutils literal">conf.py</code>.</p>
  2167. <p>To use mathematics in a post, you <strong>must</strong> set the <code class="docutils literal">has_math</code> metadata field
  2168. to <code class="docutils literal">true</code>. (Exception: posts that are Jupyter Notebooks are automatically
  2169. marked as math)</p>
  2170. <!-- Note to editors: the paragraph below uses U+200B, zero-width space. Don’t break it. -->
  2171. <p>By default, Nikola will accept <code class="docutils literal"><span class="pre">\​(...\​)</span></code> for inline math; <code class="docutils literal"><span class="pre">\​[...\​]</span></code> and
  2172. <code class="docutils literal"><span class="pre">$​$...$​$</span></code> for display math. If you want to use the old <code class="docutils literal"><span class="pre">$...$</span></code> syntax as well
  2173. (which may conflict with running text!), you need to use special config for
  2174. your renderer:</p>
  2175. <pre class="code python"><a name="rest_code_29a2de419c9648389ff48384089335bd-1"></a><span class="n">MATHJAX_CONFIG</span> <span class="o">=</span> <span class="s2">"""</span>
  2176. <a name="rest_code_29a2de419c9648389ff48384089335bd-2"></a><span class="s2">&lt;script type="text/x-mathjax-config"&gt;</span>
  2177. <a name="rest_code_29a2de419c9648389ff48384089335bd-3"></a><span class="s2">MathJax.Hub.Config({</span>
  2178. <a name="rest_code_29a2de419c9648389ff48384089335bd-4"></a><span class="s2"> tex2jax: {</span>
  2179. <a name="rest_code_29a2de419c9648389ff48384089335bd-5"></a><span class="s2"> inlineMath: [ ['$','$'], ["</span><span class="se">\\</span><span class="s2">\(","</span><span class="se">\\</span><span class="s2">\)"] ],</span>
  2180. <a name="rest_code_29a2de419c9648389ff48384089335bd-6"></a><span class="s2"> displayMath: [ ['$$','$$'], ["</span><span class="se">\\</span><span class="s2">\[","</span><span class="se">\\</span><span class="s2">\]"] ],</span>
  2181. <a name="rest_code_29a2de419c9648389ff48384089335bd-7"></a><span class="s2"> processEscapes: true</span>
  2182. <a name="rest_code_29a2de419c9648389ff48384089335bd-8"></a><span class="s2"> },</span>
  2183. <a name="rest_code_29a2de419c9648389ff48384089335bd-9"></a><span class="s2"> displayAlign: 'center', // Change this to 'left' if you want left-aligned equations.</span>
  2184. <a name="rest_code_29a2de419c9648389ff48384089335bd-10"></a><span class="s2"> "HTML-CSS": {</span>
  2185. <a name="rest_code_29a2de419c9648389ff48384089335bd-11"></a><span class="s2"> styles: {'.MathJax_Display': {"margin": 0}}</span>
  2186. <a name="rest_code_29a2de419c9648389ff48384089335bd-12"></a><span class="s2"> }</span>
  2187. <a name="rest_code_29a2de419c9648389ff48384089335bd-13"></a><span class="s2">});</span>
  2188. <a name="rest_code_29a2de419c9648389ff48384089335bd-14"></a><span class="s2">&lt;/script&gt;</span>
  2189. <a name="rest_code_29a2de419c9648389ff48384089335bd-15"></a><span class="s2">"""</span>
  2190. <a name="rest_code_29a2de419c9648389ff48384089335bd-16"></a>
  2191. <a name="rest_code_29a2de419c9648389ff48384089335bd-17"></a><span class="n">KATEX_AUTO_RENDER</span> <span class="o">=</span> <span class="s2">"""</span>
  2192. <a name="rest_code_29a2de419c9648389ff48384089335bd-18"></a><span class="s2">delimiters: [</span>
  2193. <a name="rest_code_29a2de419c9648389ff48384089335bd-19"></a><span class="s2"> {left: "$$", right: "$$", display: true},</span>
  2194. <a name="rest_code_29a2de419c9648389ff48384089335bd-20"></a><span class="s2"> {left: "</span><span class="se">\\</span><span class="s2">\[", right: "</span><span class="se">\\</span><span class="s2">\]", display: true},</span>
  2195. <a name="rest_code_29a2de419c9648389ff48384089335bd-21"></a><span class="s2"> {left: "$", right: "$", display: false},</span>
  2196. <a name="rest_code_29a2de419c9648389ff48384089335bd-22"></a><span class="s2"> {left: "</span><span class="se">\\</span><span class="s2">\(", right: "</span><span class="se">\\</span><span class="s2">\)", display: false}</span>
  2197. <a name="rest_code_29a2de419c9648389ff48384089335bd-23"></a><span class="s2">]</span>
  2198. <a name="rest_code_29a2de419c9648389ff48384089335bd-24"></a><span class="s2">"""</span>
  2199. </pre>
  2200. <p><em>(Note: the previous paragraph uses invisible characters to prevent rendering
  2201. TeX for display, so don’t copy the examples with three dots to your posts)</em></p>
  2202. </section><section id="inline-usage"><h3><a class="toc-backref" href="handbook.html#toc-entry-74" role="doc-backlink">Inline usage</a></h3>
  2203. <p>Inline mathematics are produced using the reST <cite>math</cite> <strong>role</strong> or the LaTeX
  2204. backslash-parentheses delimiters:</p>
  2205. <p>Euler’s formula: <span class="math">\(e^{ix} = \cos x + i\sin x\)</span></p>
  2206. <p>In reST:</p>
  2207. <pre class="code restructuredtext"><a name="rest_code_393ebc4ee6a64b4ca93decd5ea3c6d65-1"></a>Euler’s formula: <span class="na">:math:</span><span class="nv">`e^{ix} = \cos x + i\sin x`</span>
  2208. </pre>
  2209. <p>In HTML and other input formats:</p>
  2210. <pre class="code text"><a name="rest_code_19376130ec434673a2686d863af80f81-1"></a>Euler’s formula: \(e^{ix} = \cos x + i\sin x\)
  2211. </pre>
  2212. <p>Note that some input formats (including Markdown) require using <strong>double
  2213. backslashes</strong> in the delimiters (<code class="docutils literal"><span class="pre">\\(inline</span> <span class="pre">math\\)</span></code>). Please check your
  2214. output first before reporting bugs.</p>
  2215. </section><section id="display-usage"><h3><a class="toc-backref" href="handbook.html#toc-entry-75" role="doc-backlink">Display usage</a></h3>
  2216. <p>Display mathematics are produced using the reST <cite>math</cite> <strong>directive</strong> or the
  2217. LaTeX backslash-brackets delimiters:</p>
  2218. <div class="math">
  2219. \begin{equation*}
  2220. \int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C
  2221. \end{equation*}
  2222. </div>
  2223. <p>In reST:</p>
  2224. <pre class="code restructuredtext"><a name="rest_code_88948d9bd8b54c61a22e272d07beea37-1"></a><span class="p">..</span> <span class="ow">math</span><span class="p">::</span>
  2225. <a name="rest_code_88948d9bd8b54c61a22e272d07beea37-2"></a>
  2226. <a name="rest_code_88948d9bd8b54c61a22e272d07beea37-3"></a> \int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C
  2227. </pre>
  2228. <p>In HTML and other input formats:</p>
  2229. <pre class="code text"><a name="rest_code_7373f5fae80e40eaab5a3acb15d8c46d-1"></a>\[\int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C\]
  2230. </pre>
  2231. <p>Note that some input formats (including Markdown) require using <strong>double
  2232. backslashes</strong> in the delimiters (<code class="docutils literal"><span class="pre">\\[display</span> <span class="pre">math\\]</span></code>). Please check your
  2233. output first before reporting bugs.</p>
  2234. </section></section><section id="restructuredtext-extensions"><h2><a class="toc-backref" href="handbook.html#toc-entry-76" role="doc-backlink">reStructuredText Extensions</a></h2>
  2235. <p>Nikola includes support for a few directives and roles that are not part of docutils, but which
  2236. we think are handy for website development.</p>
  2237. <section id="includes"><h3><a class="toc-backref" href="handbook.html#toc-entry-77" role="doc-backlink">Includes</a></h3>
  2238. <p>Nikola supports the standard reStructuredText <code class="docutils literal">include</code> directive, but with a
  2239. catch: filenames are relative to <strong>Nikola site root</strong> (directory with <code class="docutils literal">conf.py</code>)
  2240. instead of the post location (eg. <code class="docutils literal">posts/</code> directory)!</p>
  2241. </section><section id="media"><h3><a class="toc-backref" href="handbook.html#toc-entry-78" role="doc-backlink">Media</a></h3>
  2242. <p>This directive lets you embed media from a variety of sites automatically by just passing the
  2243. URL of the page. For example here are two random videos:</p>
  2244. <pre class="code restructuredtext"><a name="rest_code_f6d1a5d2b5de4fe9b25f343315effd28-1"></a><span class="p">..</span> <span class="ow">media</span><span class="p">::</span> https://vimeo.com/72425090
  2245. <a name="rest_code_f6d1a5d2b5de4fe9b25f343315effd28-2"></a>
  2246. <a name="rest_code_f6d1a5d2b5de4fe9b25f343315effd28-3"></a><span class="p">..</span> <span class="ow">media</span><span class="p">::</span> https://www.youtube.com/watch?v=wyRpAat5oz0
  2247. </pre>
  2248. <p>It supports Instagram, Flickr, Github gists, Funny or Die, and dozens more, thanks to <a class="reference external" href="https://github.com/coleifer/micawber">Micawber</a></p>
  2249. </section><section id="youtube"><h3><a class="toc-backref" href="handbook.html#toc-entry-79" role="doc-backlink">YouTube</a></h3>
  2250. <p>To link to a YouTube video, you need the id of the video. For example, if the
  2251. URL of the video is <a class="reference external" href="https://www.youtube.com/watch?v=8N_tupPBtWQ">https://www.youtube.com/watch?v=8N_tupPBtWQ</a> what you need is
  2252. <strong>8N_tupPBtWQ</strong></p>
  2253. <p>Once you have that, all you need to do is:</p>
  2254. <pre class="code restructuredtext"><a name="rest_code_d65e6dc2b9794988ba0a7b4d59a895e5-1"></a><span class="p">..</span> <span class="ow">youtube</span><span class="p">::</span> 8N_tupPBtWQ
  2255. </pre>
  2256. <p>Supported options: <code class="docutils literal">height</code>, <code class="docutils literal">width</code>, <code class="docutils literal">start_at</code>, <code class="docutils literal">align</code> (one of <code class="docutils literal">left</code>,
  2257. <code class="docutils literal">center</code>, <code class="docutils literal">right</code>) — all are optional. Example:</p>
  2258. <pre class="code restructuredtext"><a name="rest_code_5994c24194594903af696e19e15a8ff1-1"></a><span class="p">..</span> <span class="ow">youtube</span><span class="p">::</span> 8N_tupPBtWQ
  2259. <a name="rest_code_5994c24194594903af696e19e15a8ff1-2"></a> <span class="nc">:align:</span> center
  2260. <a name="rest_code_5994c24194594903af696e19e15a8ff1-3"></a> <span class="nc">:start_at:</span> 4
  2261. </pre></section><section id="vimeo"><h3><a class="toc-backref" href="handbook.html#toc-entry-80" role="doc-backlink">Vimeo</a></h3>
  2262. <p>To link to a Vimeo video, you need the id of the video. For example, if the
  2263. URL of the video is <a class="reference external" href="https://vimeo.com/20241459">https://vimeo.com/20241459</a> then the id is <strong>20241459</strong></p>
  2264. <p>Once you have that, all you need to do is:</p>
  2265. <pre class="code restructuredtext"><a name="rest_code_9d22c96b9dc94462ae3e2c3dcb120133-1"></a><span class="p">..</span> <span class="ow">vimeo</span><span class="p">::</span> 20241459
  2266. </pre>
  2267. <p>If you have internet connectivity when generating your site, the height and width of
  2268. the embedded player will be set to the native height and width of the video.
  2269. You can override this if you wish:</p>
  2270. <pre class="code restructuredtext"><a name="rest_code_e750474411fd41399d4465d25eef43da-1"></a><span class="p">..</span> <span class="ow">vimeo</span><span class="p">::</span> 20241459
  2271. <a name="rest_code_e750474411fd41399d4465d25eef43da-2"></a> <span class="nc">:height:</span> 240
  2272. <a name="rest_code_e750474411fd41399d4465d25eef43da-3"></a> <span class="nc">:width:</span> 320
  2273. </pre>
  2274. <p>Supported options: <code class="docutils literal">height</code>, <code class="docutils literal">width</code>, <code class="docutils literal">align</code> (one of <code class="docutils literal">left</code>,
  2275. <code class="docutils literal">center</code>, <code class="docutils literal">right</code>) — all are optional.</p>
  2276. </section><section id="soundcloud"><h3><a class="toc-backref" href="handbook.html#toc-entry-81" role="doc-backlink">Soundcloud</a></h3>
  2277. <p>This directive lets you share music from <a class="reference external" href="https://soundcloud.com">https://soundcloud.com</a> You first need to get the
  2278. ID for the piece, which you can find in the "share" link. For example, if the
  2279. WordPress code starts like this:</p>
  2280. <pre class="code text"><a name="rest_code_16d563c463994e79bf7433a77969079e-1"></a>[soundcloud url="http://api.soundcloud.com/tracks/78131362" …/]
  2281. </pre>
  2282. <p>The ID is 78131362 and you can embed the audio with this:</p>
  2283. <pre class="code restructuredtext"><a name="rest_code_e628736d7cfd425eac28cc78532e9f7e-1"></a><span class="p">..</span> <span class="ow">soundcloud</span><span class="p">::</span> 78131362
  2284. </pre>
  2285. <p>You can also embed playlists, via the <cite>soundcloud_playlist</cite> directive which works the same way.</p>
  2286. <blockquote>
  2287. <div class="soundcloud-player">
  2288. <iframe width="600" height="160" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http://api.soundcloud.com/playlists/9411706">
  2289. </iframe>
  2290. </div>
  2291. </blockquote>
  2292. <p>Supported options: <code class="docutils literal">height</code>, <code class="docutils literal">width</code>, <code class="docutils literal">align</code> (one of <code class="docutils literal">left</code>,
  2293. <code class="docutils literal">center</code>, <code class="docutils literal">right</code>) — all are optional.</p>
  2294. </section><section id="code"><h3><a class="toc-backref" href="handbook.html#toc-entry-82" role="doc-backlink">Code</a></h3>
  2295. <p>The <code class="docutils literal">code</code> directive has been included in docutils since version 0.9 and now
  2296. replaces Nikola's <code class="docutils literal"><span class="pre">code-block</span></code> directive. To ease the transition, two aliases
  2297. for <code class="docutils literal">code</code> directive are provided: <code class="docutils literal"><span class="pre">code-block</span></code> and <code class="docutils literal">sourcecode</code>:</p>
  2298. <pre class="code restructuredtext"><a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-1"></a><span class="p">..</span> <span class="ow">code-block</span><span class="p">::</span> python
  2299. <a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-2"></a> <span class="nc">:number-lines:</span>
  2300. <a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-3"></a>
  2301. <a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-4"></a> print("Our virtues and our failings are inseparable")
  2302. </pre>
  2303. <p>Certain lines might be highlighted via the <code class="docutils literal"><span class="pre">emphasize-lines</span></code> directive:</p>
  2304. <pre class="code restructuredtext"><a name="rest_code_011532fe246d403689684094a3044cc0-1"></a><span class="p">..</span> <span class="ow">code-block</span><span class="p">::</span> python
  2305. <a name="rest_code_011532fe246d403689684094a3044cc0-2"></a> <span class="nc">:emphasize-lines:</span> 3,5
  2306. <a name="rest_code_011532fe246d403689684094a3044cc0-3"></a>
  2307. <a name="rest_code_011532fe246d403689684094a3044cc0-4"></a> def some_function():
  2308. <a name="rest_code_011532fe246d403689684094a3044cc0-5"></a> interesting = False
  2309. <a name="rest_code_011532fe246d403689684094a3044cc0-6"></a> print('This line is highlighted.')
  2310. <a name="rest_code_011532fe246d403689684094a3044cc0-7"></a> print('This one is not...')
  2311. <a name="rest_code_011532fe246d403689684094a3044cc0-8"></a> print('...but this one is.')
  2312. </pre>
  2313. <p>Line ranges are also supported, such as <code class="docutils literal"><span class="pre">:emphasize-lines:</span> <span class="pre">1-3,5-9,15</span></code>.</p>
  2314. </section><section id="listing"><h3><a class="toc-backref" href="handbook.html#toc-entry-83" role="doc-backlink">Listing</a></h3>
  2315. <p>To use this, you have to put your source code files inside <code class="docutils literal">listings</code> or whatever folders
  2316. your <code class="docutils literal">LISTINGS_FOLDERS</code> variable is set to fetch files from. Assuming you have a <code class="docutils literal">foo.py</code>
  2317. inside one of these folders:</p>
  2318. <pre class="code restructuredtext"><a name="rest_code_0489c4bbfd8243f186eb2cf25a781062-1"></a><span class="p">..</span> <span class="ow">listing</span><span class="p">::</span> foo.py python
  2319. </pre>
  2320. <p>Will include the source code from <code class="docutils literal">foo.py</code>, highlight its syntax in python mode,
  2321. and also create a <code class="docutils literal">listings/foo.py.html</code> page (or in another directory, depending on
  2322. <code class="docutils literal">LISTINGS_FOLDER</code>) and the listing will have a title linking to it.</p>
  2323. <p>The stand-alone <code class="docutils literal">listings/</code> pages also support Jupyter notebooks, if they are
  2324. supported site-wide. You must have something for <code class="docutils literal">.ipynb</code> in POSTS or PAGES
  2325. for the feature to work.</p>
  2326. <p>Listings support the same options <a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#including-an-external-document-fragment">reST includes</a> support (including
  2327. various options for controlling which parts of the file are included), and also
  2328. a <code class="docutils literal">linenos</code> option for Sphinx compatibility.</p>
  2329. <p>The <code class="docutils literal">LISTINGS_FOLDER</code> configuration variable allows to specify a list of folders where
  2330. to fetch listings from together with subfolder of the <code class="docutils literal">output</code> folder where the
  2331. processed listings should be put in. The default is, <code class="docutils literal">LISTINGS_FOLDERS = {'listings': 'listings'}</code>,
  2332. which means that all source code files in <code class="docutils literal">listings</code> will be taken and stored in <code class="docutils literal">output/listings</code>.
  2333. Extending <code class="docutils literal">LISTINGS_FOLDERS</code> to <code class="docutils literal">{'listings': 'listings', 'code': <span class="pre">'formatted-code'}</span></code>
  2334. will additionally process all source code files in <code class="docutils literal">code</code> and put the results into
  2335. <code class="docutils literal"><span class="pre">output/formatted-code</span></code>.</p>
  2336. <aside class="admonition note"><p class="admonition-title">Note</p>
  2337. <p>Formerly, <code class="docutils literal"><span class="pre">start-at</span></code> and <code class="docutils literal"><span class="pre">end-at</span></code> options were supported; however,
  2338. they do not work anymore (since v6.1.0) and you should now use <code class="docutils literal"><span class="pre">start-after</span></code>
  2339. and <code class="docutils literal"><span class="pre">end-before</span></code>, respectively. You can also use <code class="docutils literal"><span class="pre">start-line</span></code> and
  2340. <code class="docutils literal"><span class="pre">end-line</span></code>.</p>
  2341. </aside></section><section id="gist"><h3><a class="toc-backref" href="handbook.html#toc-entry-84" role="doc-backlink">Gist</a></h3>
  2342. <p>You can easily embed GitHub gists with this directive, like this:</p>
  2343. <pre class="code restructuredtext"><a name="rest_code_a6fd756ec51f4c629cdb6e9f81edeecf-1"></a><span class="p">..</span> <span class="ow">gist</span><span class="p">::</span> 2395294
  2344. </pre>
  2345. <p>Producing this:</p>
  2346. <script src="https://gist.github.com/2395294.js"></script><noscript>
  2347. <pre class="literal-block">#include &lt;stdlib.h&gt;
  2348. #include &lt;stdio.h&gt;
  2349. int nonHeapInt;
  2350. struct HeapObject
  2351. {
  2352. int x; // 因為如果找 x 的 pointer,實際上和找 HeapObject 的開頭 pointer 相同,
  2353. // 所以我們必需加一個y,讓我們指定 pointer 時不會指到 HeapObject 的開頭。
  2354. int y;
  2355. };
  2356. int main()
  2357. {
  2358. struct HeapObject * heapObject = malloc(sizeof(struct HeapObject));
  2359. nonHeapInt = 10;
  2360. heapObject-&gt;y = 20;
  2361. printf("Start nonHeapInt:%d\n", nonHeapInt);
  2362. printf("Start heapObject-&gt;y:%d\n", heapObject-&gt;y);
  2363. // free(&amp;nonHeapInt); // GCC 會警告,執行 glibc 會丟 invalid pointer exception
  2364. // free(&amp;(heapObject-&gt;y)); // 雖然不會景告,但 glibc 還是會丟 invalid pointer exception
  2365. printf("End nonHeapInt:%d\n", nonHeapInt);
  2366. printf("End heapObject-&gt;y:%d\n", heapObject-&gt;y);
  2367. }
  2368. </pre>
  2369. </noscript>
  2370. <p>This degrades gracefully if the browser doesn't support JavaScript.</p>
  2371. </section><section id="thumbnails"><h3><a class="toc-backref" href="handbook.html#toc-entry-85" role="doc-backlink">Thumbnails</a></h3>
  2372. <p>To include an image placed in the <code class="docutils literal">images</code> folder (or other folders defined in <code class="docutils literal">IMAGE_FOLDERS</code>), use the
  2373. <code class="docutils literal">thumbnail</code> directive, like this:</p>
  2374. <pre class="code restructuredtext"><a name="rest_code_549bffe9692c4ad7a4f4389128d42fa3-1"></a><span class="p">..</span> <span class="ow">thumbnail</span><span class="p">::</span> /images/tesla.jpg
  2375. <a name="rest_code_549bffe9692c4ad7a4f4389128d42fa3-2"></a> <span class="nc">:alt:</span> Nikola Tesla
  2376. </pre>
  2377. <p>The small thumbnail will be placed in the page, and it will be linked to the bigger
  2378. version of the image when clicked, using
  2379. <a class="reference external" href="https://feimosi.github.io/baguetteBox.js/">baguetteBox</a> by default. All options supported by
  2380. the reST <a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#image">image</a>
  2381. directive are supported (except <code class="docutils literal">target</code>). Providing <code class="docutils literal">alt</code> is recommended,
  2382. as this is the image caption. If a body element is provided, the thumbnail will
  2383. mimic the behavior of the <a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure">figure</a>
  2384. directive instead:</p>
  2385. <pre class="code restructuredtext"><a name="rest_code_37a0e080ea93497691ca445acb69483e-1"></a><span class="p">..</span> <span class="ow">thumbnail</span><span class="p">::</span> /images/tesla.jpg
  2386. <a name="rest_code_37a0e080ea93497691ca445acb69483e-2"></a> <span class="nc">:alt:</span> Nikola Tesla
  2387. <a name="rest_code_37a0e080ea93497691ca445acb69483e-3"></a>
  2388. <a name="rest_code_37a0e080ea93497691ca445acb69483e-4"></a> Nikola Tesla, the man that invented the 20th century.
  2389. </pre>
  2390. <p>If you want to include a thumbnail in a non-reST post, you need to produce at
  2391. least this basic HTML:</p>
  2392. <pre class="code html"><a name="rest_code_4fdc06777c7b4e77808ecc29f6a6f728-1"></a><span class="p">&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"reference"</span> <span class="na">href</span><span class="o">=</span><span class="s">"images/tesla.jpg"</span> <span class="na">alt</span><span class="o">=</span><span class="s">"Nikola Tesla"</span><span class="p">&gt;&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"images/tesla.thumbnail.jpg"</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  2393. </pre></section><section id="chart"><h3><a class="toc-backref" href="handbook.html#toc-entry-86" role="doc-backlink">Chart</a></h3>
  2394. <p>This directive is a thin wrapper around <a class="reference external" href="http://pygal.org/">Pygal</a> and will produce charts
  2395. as SVG files embedded directly in your pages.</p>
  2396. <p>Here's an example of how it works:</p>
  2397. <pre class="code restructuredtext"><a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-1"></a><span class="p">..</span> <span class="ow">chart</span><span class="p">::</span> Bar
  2398. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-2"></a> <span class="nc">:title:</span> 'Browser usage evolution (in %)'
  2399. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-3"></a> <span class="nc">:x_labels:</span> ["2002", "2003", "2004", "2005", "2006", "2007"]
  2400. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-4"></a>
  2401. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-5"></a> 'Firefox', [None, None, 0, 16.6, 25, 31]
  2402. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-6"></a> 'Chrome', [None, None, None, None, None, None]
  2403. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-7"></a> 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
  2404. <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-8"></a> 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
  2405. </pre>
  2406. <p>The argument passed next to the directive (Bar in that example) is the type of chart, and can be one of
  2407. Line, StackedLine, Bar, StackedBar, HorizontalBar, XY, DateY, Pie, Radar, Dot, Funnel, Gauge, Pyramid. For
  2408. examples of what each kind of graph is, <a class="reference external" href="http://pygal.org/en/stable/documentation/types/index.html">check here</a></p>
  2409. <p>It can take <em>a lot</em> of options to let you customize the charts (in the example, title and x_labels).
  2410. You can use any option described in <a class="reference external" href="http://pygal.org/en/stable/documentation/configuration/chart.html">the pygal docs</a></p>
  2411. <p>Finally, the content of the directive is the actual data, in the form of a label and
  2412. a list of values, one series per line.</p>
  2413. <p>You can also specify a <code class="docutils literal">:data_file:</code> option as described in the documentation for the chart shortcut.</p>
  2414. </section><section id="doc"><h3><a class="toc-backref" href="handbook.html#toc-entry-87" role="doc-backlink">Doc</a></h3>
  2415. <p>This role is useful to make links to other post or page inside the same site.</p>
  2416. <p>Here's an example:</p>
  2417. <pre class="code restructuredtext"><a name="rest_code_43165e4b4c464fdeb21e96d1cd824902-1"></a>Take a look at <span class="na">:doc:</span><span class="nv">`my other post &lt;creating-a-theme&gt;`</span> about theme creating.
  2418. </pre>
  2419. <p>In this case we are giving the portion of text we want to link. So, the result will be:</p>
  2420. <blockquote>
  2421. <p>Take a look at <a class="reference external" href="creating-a-theme.html">my other post</a> about theme creating.</p>
  2422. </blockquote>
  2423. <p>If we want to use the post's title as the link's text, just do:</p>
  2424. <pre class="code restructuredtext"><a name="rest_code_57e5bf345f144cc699afaa614b8469f6-1"></a>Take a look at <span class="na">:doc:</span><span class="nv">`creating-a-theme`</span> to know how to do it.
  2425. </pre>
  2426. <p>and it will produce:</p>
  2427. <blockquote>
  2428. <p>Take a look at <a class="reference external" href="creating-a-theme.html">Creating a Theme</a> to know how to do it.</p>
  2429. </blockquote>
  2430. <p>The reference in angular brackets should be the <cite>slug</cite> for the target page. It supports a fragment, so
  2431. things like <code class="docutils literal"><span class="pre">&lt;creating-a-theme#starting-from-somewhere&gt;</span></code> should work. You can also use the title, and
  2432. Nikola will slugify it for you, so <code class="docutils literal">Creating a theme</code> is also supported.</p>
  2433. <p>Keep in mind that the important thing is the slug. No attempt is made to check if the fragment points to
  2434. an existing location in the page, and references that don't match any page's slugs will cause warnings.</p>
  2435. </section><section id="post-list"><h3><a class="toc-backref" href="handbook.html#toc-entry-88" role="doc-backlink">Post List</a></h3>
  2436. <aside class="admonition warning"><p class="admonition-title">Warning</p>
  2437. <p>Any post or page that uses this directive will be considered out of date,
  2438. every time a post is added or deleted, causing maybe unnecessary rebuilds.</p>
  2439. <p>On the other hand, it will sometimes <strong>not</strong> be considered out of date if
  2440. a post content changes, so it can sometimes be shown outdated, in those
  2441. cases, use <code class="docutils literal">nikola build <span class="pre">-a</span></code> to force a total rebuild.</p>
  2442. </aside><p>This directive can be used to generate a list of posts. You could use it, for
  2443. example, to make a list of the latest 5 blog posts, or a list of all blog posts
  2444. with the tag <code class="docutils literal">nikola</code>:</p>
  2445. <pre class="code restructuredtext"><a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-1"></a>Here are my 5 latest and greatest blog posts:
  2446. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-2"></a>
  2447. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-3"></a><span class="p">..</span> <span class="ow">post-list</span><span class="p">::</span>
  2448. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-4"></a> <span class="nc">:stop:</span> 5
  2449. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-5"></a>
  2450. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-6"></a>These are all my posts about Nikola:
  2451. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-7"></a>
  2452. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-8"></a><span class="p">..</span> <span class="ow">post-list</span><span class="p">::</span>
  2453. <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-9"></a> <span class="nc">:tags:</span> nikola
  2454. </pre>
  2455. <p>Using shortcode syntax (for other compilers):</p>
  2456. <pre class="code text"><a name="rest_code_7897e663e40d4ffdb57699fb19e12cb0-1"></a>{{% post-list stop=5 %}}{{% /post-list %}}
  2457. </pre>
  2458. <p>The following options are recognized:</p>
  2459. <ul class="simple">
  2460. <li><dl class="simple">
  2461. <dt>
  2462. <code class="docutils literal">start</code><span class="classifier">integer</span>
  2463. </dt>
  2464. <dd>
  2465. <p>The index of the first post to show.
  2466. A negative value like <code class="docutils literal"><span class="pre">-3</span></code> will show the <em>last</em> three posts in the
  2467. post-list.
  2468. Defaults to None.</p>
  2469. </dd>
  2470. </dl></li>
  2471. <li><dl class="simple">
  2472. <dt>
  2473. <code class="docutils literal">stop</code><span class="classifier">integer</span>
  2474. </dt>
  2475. <dd>
  2476. <p>The index of the last post to show.
  2477. A value negative value like <code class="docutils literal"><span class="pre">-1</span></code> will show every post, but not the
  2478. <em>last</em> in the post-list.
  2479. Defaults to None.</p>
  2480. </dd>
  2481. </dl></li>
  2482. <li><dl class="simple">
  2483. <dt>
  2484. <code class="docutils literal">reverse</code><span class="classifier">flag</span>
  2485. </dt>
  2486. <dd>
  2487. <p>Reverse the order of the post-list.
  2488. Defaults is to not reverse the order of posts.</p>
  2489. </dd>
  2490. </dl></li>
  2491. <li><dl class="simple">
  2492. <dt>
  2493. <code class="docutils literal">sort</code>: string</dt>
  2494. <dd>
  2495. <p>Sort post list by one of each post's attributes, usually <code class="docutils literal">title</code> or a
  2496. custom <code class="docutils literal">priority</code>. Defaults to None (chronological sorting).</p>
  2497. </dd>
  2498. </dl></li>
  2499. <li><dl class="simple">
  2500. <dt>
  2501. <code class="docutils literal">date</code>: string</dt>
  2502. <dd>
  2503. <p>Show posts that match date range specified by this option. Format:</p>
  2504. <ul>
  2505. <li><p>comma-separated clauses (AND)</p></li>
  2506. <li><dl class="simple">
  2507. <dt>clause: attribute comparison_operator value (spaces optional)</dt>
  2508. <dd><ul>
  2509. <li><p>attribute: year, month, day, hour, month, second, weekday, isoweekday; or empty for full datetime</p></li>
  2510. <li><p>comparison_operator: == != &lt;= &gt;= &lt; &gt;</p></li>
  2511. <li><p>value: integer, 'now', 'today', or dateutil-compatible date input</p></li>
  2512. </ul></dd>
  2513. </dl></li>
  2514. </ul>
  2515. </dd>
  2516. </dl></li>
  2517. <li><dl class="simple">
  2518. <dt>
  2519. <code class="docutils literal">tags</code><span class="classifier">string [, string...]</span>
  2520. </dt>
  2521. <dd>
  2522. <p>Filter posts to show only posts having at least one of the <code class="docutils literal">tags</code>.
  2523. Defaults to None.</p>
  2524. </dd>
  2525. </dl></li>
  2526. <li><dl class="simple">
  2527. <dt>
  2528. <code class="docutils literal">require_all_tags</code><span class="classifier">flag</span>
  2529. </dt>
  2530. <dd>
  2531. <p>Change tag filter behaviour to show only posts that have all specified <code class="docutils literal">tags</code>.
  2532. Defaults to False.</p>
  2533. </dd>
  2534. </dl></li>
  2535. <li><dl class="simple">
  2536. <dt>
  2537. <code class="docutils literal">categories</code><span class="classifier">string [, string...]</span>
  2538. </dt>
  2539. <dd>
  2540. <p>Filter posts to show only posts having one of the <code class="docutils literal">categories</code>.
  2541. Defaults to None.</p>
  2542. </dd>
  2543. </dl></li>
  2544. <li><dl class="simple">
  2545. <dt>
  2546. <code class="docutils literal">slugs</code><span class="classifier">string [, string...]</span>
  2547. </dt>
  2548. <dd>
  2549. <p>Filter posts to show only posts having at least one of the <code class="docutils literal">slugs</code>.
  2550. Defaults to None.</p>
  2551. </dd>
  2552. </dl></li>
  2553. <li><dl class="simple">
  2554. <dt>
  2555. <code class="docutils literal">post_type</code> (or <code class="docutils literal">type</code>)<span class="classifier">string</span>
  2556. </dt>
  2557. <dd>
  2558. <p>Show only <code class="docutils literal">posts</code>, <code class="docutils literal">pages</code> or <code class="docutils literal">all</code>.
  2559. Replaces <code class="docutils literal">all</code>. Defaults to <code class="docutils literal">posts</code>.</p>
  2560. </dd>
  2561. </dl></li>
  2562. <li><dl class="simple">
  2563. <dt>
  2564. <code class="docutils literal">all</code><span class="classifier">flag</span>
  2565. </dt>
  2566. <dd>
  2567. <p>(deprecated, use <code class="docutils literal">post_type</code> instead)
  2568. Shows all posts and pages in the post list. Defaults to show only posts.</p>
  2569. </dd>
  2570. </dl></li>
  2571. <li><dl class="simple">
  2572. <dt>
  2573. <code class="docutils literal">lang</code><span class="classifier">string</span>
  2574. </dt>
  2575. <dd>
  2576. <p>The language of post <em>titles</em> and <em>links</em>.
  2577. Defaults to default language.</p>
  2578. </dd>
  2579. </dl></li>
  2580. <li><dl class="simple">
  2581. <dt>
  2582. <code class="docutils literal">template</code><span class="classifier">string</span>
  2583. </dt>
  2584. <dd>
  2585. <p>The name of an alternative template to render the post-list.
  2586. Defaults to <code class="docutils literal">post_list_directive.tmpl</code></p>
  2587. </dd>
  2588. </dl></li>
  2589. <li><dl class="simple">
  2590. <dt>
  2591. <code class="docutils literal">id</code><span class="classifier">string</span>
  2592. </dt>
  2593. <dd>
  2594. <p>A manual id for the post list.
  2595. Defaults to a random name composed by <code class="docutils literal">'post_list_' + <span class="pre">uuid.uuid4().hex</span></code>.</p>
  2596. </dd>
  2597. </dl></li>
  2598. </ul>
  2599. <p>The post list directive uses the <code class="docutils literal">post_list_directive.tmpl</code> template file (or
  2600. another one, if you use the <code class="docutils literal">template</code> option) to generate the list's HTML. By
  2601. default, this is an unordered list with dates and clickable post titles. See
  2602. the template file in Nikola's base theme for an example of how this works.</p>
  2603. <p>The list may fail to update in some cases, please run <code class="docutils literal">nikola build <span class="pre">-a</span></code> with
  2604. the appropriate path if this happens.</p>
  2605. <p>We recommend using pages with dates in the past (1970-01-01) to avoid
  2606. dependency issues.</p>
  2607. <p>If you are using this as a shortcode, flags (<code class="docutils literal">reverse</code>, <code class="docutils literal">all</code>) are meant to be used
  2608. with a <code class="docutils literal">True</code> argument, eg. <code class="docutils literal">all=True</code>.</p>
  2609. <aside class="sidebar"><p class="sidebar-title">Docutils Configuration</p>
  2610. <p>ReStructured Text is "compiled" by docutils, which supports a number of
  2611. configuration options. It would be difficult to integrate them all into
  2612. Nikola's configuration, so you can just put a <code class="docutils literal">docutils.conf</code> next
  2613. to your <code class="docutils literal">conf.py</code> and any settings in its <code class="docutils literal">[nikola]</code> section will be used.</p>
  2614. <p>More information in the <a class="reference external" href="https://docutils.sourceforge.io/docs/user/config.html">docutils configuration reference</a></p>
  2615. </aside></section></section><section id="importing-your-wordpress-site-into-nikola"><h2><a class="toc-backref" href="handbook.html#toc-entry-89" role="doc-backlink">Importing your WordPress site into Nikola</a></h2>
  2616. <p>If you like Nikola, and want to start using it, but you have a WordPress blog, Nikola
  2617. supports importing it. Here are the steps to do it:</p>
  2618. <ol class="arabic simple">
  2619. <li><p>Get an XML dump of your site <a class="footnote-reference brackets" href="handbook.html#footnote-1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></li>
  2620. <li><p><code class="docutils literal">nikola import_wordpress <span class="pre">mysite.wordpress.2012-12-20.xml</span></code></p></li>
  2621. </ol>
  2622. <p>After some time, this will create a <code class="docutils literal">new_site</code> folder with all your data. It currently supports
  2623. the following:</p>
  2624. <ul>
  2625. <li><p>All your posts and pages</p></li>
  2626. <li><p>Keeps “draft” status</p></li>
  2627. <li><p>Your tags and categories</p></li>
  2628. <li><p>Imports your attachments and fixes links to point to the right places</p></li>
  2629. <li><p>Will try to add redirects that send the old post URLs to the new ones</p></li>
  2630. <li>
  2631. <p>Will give you a URL map so you know where each old post was</p>
  2632. <p>This is also useful for DISQUS thread migration, or server-based 301
  2633. redirects!</p>
  2634. </li>
  2635. <li><p>Allows you to export your comments with each post</p></li>
  2636. <li><p>Exports information on attachments per post</p></li>
  2637. <li>
  2638. <p>There are different methods to transfer the content of your posts:</p>
  2639. <ul>
  2640. <li>
  2641. <p>You can convert them to HTML with the WordPress page compiler plugin
  2642. for Nikola. This will format the posts including supported shortcodes
  2643. the same way as WordPress does. Use the <code class="docutils literal"><span class="pre">--transform-to-html</span></code> option
  2644. to convert your posts to HTML.</p>
  2645. <p>If you use this option, you do not need to install the plugin
  2646. permanently. You can ask Nikola to install the plugin into the subdirectory
  2647. <code class="docutils literal">plugins</code> of the current working directory by specifying
  2648. the <code class="docutils literal"><span class="pre">--install-wordpress-compiler</span></code> option.</p>
  2649. </li>
  2650. <li>
  2651. <p>You can leave the posts the way they are and use the WordPress page
  2652. compiler plugin to render them when building your new blog. This also
  2653. allows you to create new posts using the WordPress syntax, or to manually
  2654. add more shortcode plugins later. Use the <code class="docutils literal"><span class="pre">--use-wordpress-compiler</span></code>
  2655. option to not touch your posts.</p>
  2656. <p>If you want to use this option, you have to install the plugin permanently.
  2657. You can ask Nikola to install the plugin into your new site by specifying
  2658. the <code class="docutils literal"><span class="pre">--install-wordpress-compiler</span></code> option.</p>
  2659. </li>
  2660. <li><p>You can let Nikola convert your posts to Markdown. This is <em>not</em> error
  2661. free, because WordPress uses some unholy mix of HTML and strange things.
  2662. This is the default option and requires no plugins.</p></li>
  2663. </ul>
  2664. <p>You will find your old posts in <code class="docutils literal"><span class="pre">new_site/posts/post-title.html</span></code> in the first case,
  2665. <code class="docutils literal"><span class="pre">new_site/posts/post-title.wp</span></code> in the second case or <code class="docutils literal"><span class="pre">new_site/posts/post-title.md</span></code>
  2666. in the last case if you need to edit or fix any of them.</p>
  2667. <p>Please note that the page compiler currently only supports the <code class="docutils literal">[code]</code> shortcode,
  2668. but other shortcodes can be supported via plugins.</p>
  2669. <p>Also note that the WordPress page compiler is licensed under GPL v2 since
  2670. it uses code from WordPress itself, while Nikola is licensed under the more
  2671. liberal MIT license.</p>
  2672. </li>
  2673. </ul>
  2674. <p>This feature is a work in progress, and the only way to improve it is to have it used for
  2675. as many sites as possible and make it work better each time, so we are happy to get requests
  2676. about it.</p>
  2677. <aside class="footnote-list brackets"><aside class="footnote brackets" id="footnote-1" role="note"><span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="handbook.html#footnote-reference-1">1</a><span class="fn-bracket">]</span></span>
  2678. <p>The dump needs to be in 1.2 format. You can check by reading it, it should say
  2679. <code class="docutils literal"><span class="pre">xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"</span></code> near the top of the
  2680. file. If it says <code class="docutils literal">1.1</code> instead of <code class="docutils literal">1.2</code> you will have to update your
  2681. WordPress before dumping.</p>
  2682. <p>Other versions may or may not work.</p>
  2683. </aside></aside><section id="importing-to-a-custom-location-or-into-an-existing-site"><h3><a class="toc-backref" href="handbook.html#toc-entry-90" role="doc-backlink">Importing to a custom location or into an existing site</a></h3>
  2684. <p>It is possible to either import into a location you desire or into an already existing Nikola site.
  2685. To do so you can specify a location after the dump:</p>
  2686. <pre class="code console"><a name="rest_code_909cd90914e441c2baf7584322209a79-1"></a><span class="gp">$</span> nikola import_wordpress mysite.wordpress.2012-12-20.xml -o import_location
  2687. </pre>
  2688. <p>With this command Nikola will import into the folder <code class="docutils literal">import_location</code>.</p>
  2689. <p>If the folder already exists Nikola will not overwrite an existing <code class="docutils literal">conf.py</code>.
  2690. Instead a new file with a timestamp at the end of the filename will be created.</p>
  2691. </section></section><section id="using-twitter-cards"><h2><a class="toc-backref" href="handbook.html#toc-entry-91" role="doc-backlink">Using Twitter Cards</a></h2>
  2692. <p>Nikola supports Twitter Card summaries, but they are disabled by default.</p>
  2693. <p>Twitter Cards enable you to show additional information in Tweets that link
  2694. to your content.
  2695. Nikola supports <a class="reference external" href="https://dev.twitter.com/docs/cards">Twitter Cards</a>.
  2696. They are implemented to use <em>Open Graph</em> tags whenever possible.</p>
  2697. <p>Images displayed come from the <cite>previewimage</cite> meta tag.</p>
  2698. <p>You can specify the card type by using the <cite>card</cite> parameter in TWITTER_CARD.</p>
  2699. <p>To enable and configure your use of Twitter Cards, please modify the
  2700. corresponding lines in your <code class="docutils literal">conf.py</code>:</p>
  2701. <pre class="code python"><a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-1"></a><span class="n">TWITTER_CARD</span> <span class="o">=</span> <span class="p">{</span>
  2702. <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-2"></a> <span class="s1">'use_twitter_cards'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="c1"># enable Twitter Cards</span>
  2703. <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-3"></a> <span class="s1">'card'</span><span class="p">:</span> <span class="s1">'summary'</span><span class="p">,</span> <span class="c1"># Card type, you can also use 'summary_large_image',</span>
  2704. <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-4"></a> <span class="c1"># see https://dev.twitter.com/cards/types</span>
  2705. <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-5"></a> <span class="s1">'site'</span><span class="p">:</span> <span class="s1">'@website'</span><span class="p">,</span> <span class="c1"># twitter nick for the website</span>
  2706. <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-6"></a> <span class="s1">'creator'</span><span class="p">:</span> <span class="s1">'@username'</span><span class="p">,</span> <span class="c1"># Username for the content creator / author.</span>
  2707. <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-7"></a><span class="p">}</span>
  2708. </pre></section><section id="custom-plugins"><h2><a class="toc-backref" href="handbook.html#toc-entry-92" role="doc-backlink">Custom Plugins</a></h2>
  2709. <p>You can create your own plugins (see <a class="reference external" href="extending.html">Extending Nikola</a>) and use them in your own
  2710. site by putting them in a <code class="docutils literal">plugins/</code> folder. You can also put them in
  2711. directories listed in the <code class="docutils literal">EXTRA_PLUGINS_DIRS</code> configuration variable.</p>
  2712. </section><section id="getting-extra-plugins"><h2><a class="toc-backref" href="handbook.html#toc-entry-93" role="doc-backlink">Getting Extra Plugins</a></h2>
  2713. <p>If you want extra plugins, there is also the <a class="reference external" href="https://plugins.getnikola.com/">Plugins Index</a>.</p>
  2714. <p>Similarly to themes, there is a nice, built-in command to manage them —
  2715. <code class="docutils literal">plugin</code>:</p>
  2716. <pre class="code console"><a name="rest_code_3afc51eaae9249348be77faf328a4711-1"></a><span class="gp">$</span> nikola plugin -l
  2717. <a name="rest_code_3afc51eaae9249348be77faf328a4711-2"></a><span class="go">Plugins:</span>
  2718. <a name="rest_code_3afc51eaae9249348be77faf328a4711-3"></a><span class="go">--------</span>
  2719. <a name="rest_code_3afc51eaae9249348be77faf328a4711-4"></a><span class="go">helloworld</span>
  2720. <a name="rest_code_3afc51eaae9249348be77faf328a4711-5"></a><span class="go">tags</span>
  2721. <a name="rest_code_3afc51eaae9249348be77faf328a4711-6"></a><span class="go">⋮</span>
  2722. <a name="rest_code_3afc51eaae9249348be77faf328a4711-7"></a><span class="go">⋮</span>
  2723. <a name="rest_code_3afc51eaae9249348be77faf328a4711-8"></a>
  2724. <a name="rest_code_3afc51eaae9249348be77faf328a4711-9"></a><span class="gp">$</span> nikola plugin --install helloworld
  2725. <a name="rest_code_3afc51eaae9249348be77faf328a4711-10"></a><span class="go">[2013-10-12T16:51:56Z] NOTICE: install_plugin: Downloading: https://plugins.getnikola.com/v6/helloworld.zip</span>
  2726. <a name="rest_code_3afc51eaae9249348be77faf328a4711-11"></a><span class="go">[2013-10-12T16:51:58Z] NOTICE: install_plugin: Extracting: helloworld into plugins</span>
  2727. <a name="rest_code_3afc51eaae9249348be77faf328a4711-12"></a><span class="go">plugins/helloworld/requirements.txt</span>
  2728. <a name="rest_code_3afc51eaae9249348be77faf328a4711-13"></a><span class="go">[2013-10-12T16:51:58Z] NOTICE: install_plugin: This plugin has Python dependencies.</span>
  2729. <a name="rest_code_3afc51eaae9249348be77faf328a4711-14"></a><span class="go">[2013-10-12T16:51:58Z] NOTICE: install_plugin: Installing dependencies with pip...</span>
  2730. <a name="rest_code_3afc51eaae9249348be77faf328a4711-15"></a><span class="go">⋮</span>
  2731. <a name="rest_code_3afc51eaae9249348be77faf328a4711-16"></a><span class="go">⋮</span>
  2732. <a name="rest_code_3afc51eaae9249348be77faf328a4711-17"></a><span class="go">[2013-10-12T16:51:59Z] NOTICE: install_plugin: Dependency installation succeeded.</span>
  2733. <a name="rest_code_3afc51eaae9249348be77faf328a4711-18"></a><span class="go">[2013-10-12T16:51:59Z] NOTICE: install_plugin: This plugin has a sample config file.</span>
  2734. <a name="rest_code_3afc51eaae9249348be77faf328a4711-19"></a><span class="go">Contents of the conf.py.sample file:</span>
  2735. <a name="rest_code_3afc51eaae9249348be77faf328a4711-20"></a>
  2736. <a name="rest_code_3afc51eaae9249348be77faf328a4711-21"></a><span class="gp"> #</span> Should the Hello World plugin say “BYE” instead?
  2737. <a name="rest_code_3afc51eaae9249348be77faf328a4711-22"></a><span class="go"> BYE_WORLD = False</span>
  2738. </pre>
  2739. <p>Then you also can uninstall your plugins:</p>
  2740. <pre class="code console"><a name="rest_code_a34dbbe949e04b83b778e7d599622eae-1"></a><span class="gp">$</span> nikola plugin --uninstall tags
  2741. <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-2"></a><span class="go">[2014-04-15T08:59:24Z] WARNING: plugin: About to uninstall plugin: tags</span>
  2742. <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-3"></a><span class="go">[2014-04-15T08:59:24Z] WARNING: plugin: This will delete /home/ralsina/foo/plugins/tags</span>
  2743. <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-4"></a><span class="go">Are you sure? [y/n] y</span>
  2744. <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-5"></a><span class="go">[2014-04-15T08:59:26Z] WARNING: plugin: Removing /home/ralsina/foo/plugins/tags</span>
  2745. </pre>
  2746. <p>And upgrade them:</p>
  2747. <pre class="code console"><a name="rest_code_24342a29a808464f92514eb66426302c-1"></a><span class="gp">$</span> nikola plugin --upgrade
  2748. <a name="rest_code_24342a29a808464f92514eb66426302c-2"></a><span class="go">[2014-04-15T09:00:18Z] WARNING: plugin: This is not very smart, it just reinstalls some plugins and hopes for the best</span>
  2749. <a name="rest_code_24342a29a808464f92514eb66426302c-3"></a><span class="go">Will upgrade 1 plugins: graphviz</span>
  2750. <a name="rest_code_24342a29a808464f92514eb66426302c-4"></a><span class="go">Upgrading graphviz</span>
  2751. <a name="rest_code_24342a29a808464f92514eb66426302c-5"></a><span class="go">[2014-04-15T09:00:20Z] INFO: plugin: Downloading: https://plugins.getnikola.com/v7/graphviz.zip</span>
  2752. <a name="rest_code_24342a29a808464f92514eb66426302c-6"></a><span class="go">[2014-04-15T09:00:20Z] INFO: plugin: Extracting: graphviz into /home/ralsina/.nikola/plugins/</span>
  2753. <a name="rest_code_24342a29a808464f92514eb66426302c-7"></a><span class="go">[2014-04-15T09:00:20Z] NOTICE: plugin: This plugin has third-party dependencies you need to install manually.</span>
  2754. <a name="rest_code_24342a29a808464f92514eb66426302c-8"></a><span class="go">Contents of the requirements-nonpy.txt file:</span>
  2755. <a name="rest_code_24342a29a808464f92514eb66426302c-9"></a>
  2756. <a name="rest_code_24342a29a808464f92514eb66426302c-10"></a><span class="go"> Graphviz</span>
  2757. <a name="rest_code_24342a29a808464f92514eb66426302c-11"></a><span class="go"> https://www.graphviz.org/</span>
  2758. <a name="rest_code_24342a29a808464f92514eb66426302c-12"></a>
  2759. <a name="rest_code_24342a29a808464f92514eb66426302c-13"></a><span class="go">You have to install those yourself or through a package manager.</span>
  2760. </pre>
  2761. <p>You can also share plugins you created with the community! Visit the
  2762. <a class="reference external" href="https://github.com/getnikola/plugins">GitHub repository</a> to find out more.</p>
  2763. <p>You can use the plugins in this repository without installing them into your
  2764. site, by cloning the repository and adding the path of the plugins directory to
  2765. the <code class="docutils literal">EXTRA_PLUGINS_DIRS</code> list in your configuration.</p>
  2766. </section><section id="advanced-features"><h2><a class="toc-backref" href="handbook.html#toc-entry-94" role="doc-backlink">Advanced Features</a></h2>
  2767. <section id="debugging"><h3><a class="toc-backref" href="handbook.html#toc-entry-95" role="doc-backlink">Debugging</a></h3>
  2768. <p>For pdb debugging in Nikola, you should use <code class="docutils literal">doit.tools.set_trace()</code> instead
  2769. of the usual pdb call. By default, doit (and thus Nikola) redirects stdout and
  2770. stderr. Thus, you must use the different call. (Alternatively, you could run
  2771. with <code class="docutils literal">nikola build <span class="pre">-v</span> 2</code>, which disables the redirections.)</p>
  2772. <p>To show more logging messages, as well as full tracebacks, you need to set an
  2773. environment variable: <code class="docutils literal">NIKOLA_DEBUG=1</code>. If you want to only see tracebacks,
  2774. set <code class="docutils literal">NIKOLA_SHOW_TRACEBACKS=1</code>.</p>
  2775. </section><section id="shell-tab-completion"><h3><a class="toc-backref" href="handbook.html#toc-entry-96" role="doc-backlink">Shell Tab Completion</a></h3>
  2776. <p>Since Nikola is a command line tool, and this is the 21st century, it's handy to have smart tab-completion
  2777. so that you don't have to type the full commands.</p>
  2778. <p>To enable this, you can use the <code class="docutils literal">nikola tabcompletion</code> command like this,
  2779. depending on your shell:</p>
  2780. <pre class="code console"><a name="rest_code_11b92258c62841bb95f453aef9a976b4-1"></a><span class="gp">$</span> nikola tabcompletion --shell bash --hardcode-tasks &gt; _nikola_bash
  2781. <a name="rest_code_11b92258c62841bb95f453aef9a976b4-2"></a><span class="gp">$</span> nikola tabcompletion --shell zsh --hardcode-tasks &gt; _nikola_zsh
  2782. </pre>
  2783. <p>The <code class="docutils literal"><span class="pre">--hardcode-tasks</span></code> adds tasks to the completion and may need updating periodically.</p>
  2784. <p>Please refer to your shell’s documentation for help on how to use those files.</p>
  2785. </section></section><section id="license"><h2><a class="toc-backref" href="handbook.html#toc-entry-97" role="doc-backlink">License</a></h2>
  2786. <p>Nikola is released under the <a class="reference external" href="https://getnikola.com/license.html">MIT license</a>, which is a free software license. Some
  2787. components shipped along with Nikola, or required by it are released under
  2788. other licenses.</p>
  2789. <p>If you are not familiar with free software licensing, here is a brief
  2790. explanation (this is NOT legal advice): In general, you can do pretty much
  2791. anything you want — including modifying Nikola, using and redistributing the
  2792. original version or the your modified version. However, if you redistribute
  2793. Nikola to someone else, either a modified version or the original version, the
  2794. full copyright notice and license text must be included in your distribution.
  2795. Nikola is provided “as is”, and the Nikola contributors are not liable for any
  2796. damage caused by the software. Read the <a class="reference external" href="https://getnikola.com/license.html">full license text</a> for details.</p>
  2797. </section>
  2798. </div>
  2799. <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" integrity="sha384-3lJUsx1TJHt7BA4udB5KPnDrlkO8T6J6v/op7ui0BbCjvZ9WqV4Xm6DTP6kQ/iBH" crossorigin="anonymous"></script><script type="text/x-mathjax-config">
  2800. MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});
  2801. </script></article>
  2802. </div>
  2803. <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
  2804. <div class="sidebar-module sidebar-module-inset">
  2805. <h4>About</h4>
  2806. <div id="shoutcastdiv">
  2807. <script type="text/javascript">
  2808. refreshdiv();
  2809. </script>
  2810. </div>
  2811. </div>
  2812. <div class="sidebar-module">
  2813. <h4>Links</h4>
  2814. <ol class="list-unstyled">
  2815. <li><a href="http://getbootstrap.com/examples/blog/">Bootstrap Blog Theme</a></li>
  2816. <li><a href="https://getnikola.com/">Nikola</a></li>
  2817. <li><a href="https://twitter.com/mdo">@mdo</a></li>
  2818. <li><a href="https://twitter.com/Kwpolska">@Kwpolska</a></li>
  2819. <li><a href="https://twitter.com/GetNikola">@GetNikola</a></li>
  2820. </ol>
  2821. </div>
  2822. </div>
  2823. <!--End of body content-->
  2824. </div>
  2825. </div>
  2826. </div>
  2827. <footer class="blog-footer" id="footer">
  2828. Contents © 2023 <a href="mailto:contact@riff-radio.org">Riff</a> - Powered by <a href="https://getnikola.com" rel="nofollow">Nikola</a>
  2829. </footer><script src="../assets/js/all-nocdn.js"></script><!-- fancy dates --><script>
  2830. moment.locale("en");
  2831. fancydates(0, "YYYY-MM-DD HH:mm");
  2832. </script><!-- end fancy dates --><script>
  2833. baguetteBox.run('div#content', {
  2834. ignoreClass: 'islink',
  2835. captions: function(element) {
  2836. return element.getElementsByTagName('img')[0].alt;
  2837. }});
  2838. </script><script type="text/javascript" src="../refresh.js"></script>
  2839. </body>
  2840. </html>