12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774 |
- <dl class="docinfo simple">
- <dt class="version">Version<span class="colon">:</span></dt>
- <dd class="version">8.2.3</dd>
- </dl>
- <nav class="contents alert alert-primary float-md-right" id="contents" role="doc-toc">
- <p class="topic-title">Contents</p>
- <ul class="simple">
- <li><p><a class="reference internal" href="#all-you-need-to-know" id="toc-entry-1">All You Need to Know</a></p></li>
- <li><p><a class="reference internal" href="#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>
- <li><p><a class="reference internal" href="#getting-help" id="toc-entry-3">Getting Help</a></p></li>
- <li><p><a class="reference internal" href="#why-static" id="toc-entry-4">Why Static?</a></p></li>
- <li><p><a class="reference internal" href="#components" id="toc-entry-5">Components</a></p></li>
- <li><p><a class="reference internal" href="#getting-started" id="toc-entry-6">Getting Started</a></p></li>
- <li><p><a class="reference internal" href="#creating-a-blog-post" id="toc-entry-7">Creating a Blog Post</a></p>
- <ul>
- <li><p><a class="reference internal" href="#metadata-fields" id="toc-entry-8">Metadata fields</a></p>
- <ul>
- <li><p><a class="reference internal" href="#basic" id="toc-entry-9">Basic</a></p></li>
- <li><p><a class="reference internal" href="#extra" id="toc-entry-10">Extra</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#metadata-formats" id="toc-entry-11">Metadata formats</a></p>
- <ul>
- <li><p><a class="reference internal" href="#rest-style-comments" id="toc-entry-12">reST-style comments</a></p></li>
- <li><p><a class="reference internal" href="#two-file-format" id="toc-entry-13">Two-file format</a></p></li>
- <li><p><a class="reference internal" href="#jupyter-notebook-metadata" id="toc-entry-14">Jupyter Notebook metadata</a></p></li>
- <li><p><a class="reference internal" href="#yaml-metadata" id="toc-entry-15">YAML metadata</a></p></li>
- <li><p><a class="reference internal" href="#toml-metadata" id="toc-entry-16">TOML metadata</a></p></li>
- <li><p><a class="reference internal" href="#rest-docinfo" id="toc-entry-17">reST docinfo</a></p></li>
- <li><p><a class="reference internal" href="#pelican-markdown-metadata" id="toc-entry-18">Pelican/Markdown metadata</a></p></li>
- <li><p><a class="reference internal" href="#html-meta-tags" id="toc-entry-19">HTML meta tags</a></p></li>
- <li><p><a class="reference internal" href="#mapping-metadata-from-other-formats" id="toc-entry-20">Mapping metadata from other formats</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#multilingual-posts" id="toc-entry-21">Multilingual posts</a></p></li>
- <li><p><a class="reference internal" href="#how-does-nikola-decide-where-posts-should-go" id="toc-entry-22">How does Nikola decide where posts should go?</a></p></li>
- <li><p><a class="reference internal" href="#the-new-post-command" id="toc-entry-23">The <code class="docutils literal">new_post</code> command</a></p></li>
- <li><p><a class="reference internal" href="#teasers" id="toc-entry-24">Teasers</a></p></li>
- <li><p><a class="reference internal" href="#drafts" id="toc-entry-25">Drafts</a></p></li>
- <li><p><a class="reference internal" href="#private-posts" id="toc-entry-26">Private Posts</a></p></li>
- <li><p><a class="reference internal" href="#featured-posts" id="toc-entry-27">Featured Posts</a></p></li>
- <li><p><a class="reference internal" href="#queuing-posts" id="toc-entry-28">Queuing Posts</a></p></li>
- <li><p><a class="reference internal" href="#post-types" id="toc-entry-29">Post Types</a></p></li>
- <li><p><a class="reference internal" href="#indexes" id="toc-entry-30">Indexes</a></p>
- <ul>
- <li><p><a class="reference internal" href="#settings" id="toc-entry-31">Settings</a></p></li>
- <li><p><a class="reference internal" href="#static-indexes" id="toc-entry-32">Static indexes</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#post-taxonomy" id="toc-entry-33">Post taxonomy</a></p>
- <ul>
- <li><p><a class="reference internal" href="#tags" id="toc-entry-34">Tags</a></p></li>
- <li><p><a class="reference internal" href="#categories" id="toc-entry-35">Categories</a></p></li>
- <li><p><a class="reference internal" href="#configuring-tags-and-categories" id="toc-entry-36">Configuring tags and categories</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#what-if-i-dont-want-a-blog" id="toc-entry-37">What if I don’t want a blog?</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#creating-a-page" id="toc-entry-38">Creating a Page</a></p></li>
- <li><p><a class="reference internal" href="#supported-input-formats" id="toc-entry-39">Supported input formats</a></p>
- <ul>
- <li><p><a class="reference internal" href="#configuring-other-input-formats" id="toc-entry-40">Configuring other input formats</a></p>
- <ul>
- <li><p><a class="reference internal" href="#markdown" id="toc-entry-41">Markdown</a></p></li>
- <li><p><a class="reference internal" href="#jupyter-notebook" id="toc-entry-42">Jupyter Notebook</a></p></li>
- <li><p><a class="reference internal" href="#html" id="toc-entry-43">HTML</a></p></li>
- <li><p><a class="reference internal" href="#php" id="toc-entry-44">PHP</a></p></li>
- <li><p><a class="reference internal" href="#pandoc" id="toc-entry-45">Pandoc</a></p></li>
- </ul>
- </li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#shortcodes" id="toc-entry-46">Shortcodes</a></p>
- <ul>
- <li><p><a class="reference internal" href="#using-a-shortcode" id="toc-entry-47">Using a shortcode</a></p></li>
- <li><p><a class="reference internal" href="#built-in-shortcodes" id="toc-entry-48">Built-in shortcodes</a></p></li>
- <li><p><a class="reference internal" href="#community-shortcodes" id="toc-entry-49">Community shortcodes</a></p></li>
- <li><p><a class="reference internal" href="#template-based-shortcodes" id="toc-entry-50">Template-based shortcodes</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#the-global-context-and-data-files" id="toc-entry-51">The Global Context and Data files</a></p></li>
- <li><p><a class="reference internal" href="#redirections" id="toc-entry-52">Redirections</a></p></li>
- <li><p><a class="reference internal" href="#configuration" id="toc-entry-53">Configuration</a></p></li>
- <li><p><a class="reference internal" href="#customizing-your-site" id="toc-entry-54">Customizing Your Site</a></p></li>
- <li><p><a class="reference internal" href="#fancy-dates" id="toc-entry-55">Fancy Dates</a></p></li>
- <li><p><a class="reference internal" href="#adding-files" id="toc-entry-56">Adding Files</a></p></li>
- <li><p><a class="reference internal" href="#custom-themes" id="toc-entry-57">Custom Themes</a></p></li>
- <li><p><a class="reference internal" href="#getting-extra-themes" id="toc-entry-58">Getting Extra Themes</a></p></li>
- <li><p><a class="reference internal" href="#deployment" id="toc-entry-59">Deployment</a></p>
- <ul>
- <li><p><a class="reference internal" href="#deploying-to-github" id="toc-entry-60">Deploying to GitHub</a></p></li>
- <li><p><a class="reference internal" href="#automated-rebuilds-github-actions-gitlab" id="toc-entry-61">Automated rebuilds (GitHub Actions, GitLab)</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#comments" id="toc-entry-62">Comments</a></p></li>
- <li><p><a class="reference internal" href="#images-and-galleries" id="toc-entry-63">Images and Galleries</a></p>
- <ul>
- <li><p><a class="reference internal" href="#embedding-images" id="toc-entry-64">Embedding Images</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#handling-exif-data" id="toc-entry-65">Handling EXIF Data</a></p>
- <ul>
- <li><p><a class="reference internal" href="#strip-all-exif-data" id="toc-entry-66">Strip all EXIF data</a></p></li>
- <li><p><a class="reference internal" href="#preserve-all-exif-data" id="toc-entry-67">Preserve all EXIF data</a></p></li>
- <li><p><a class="reference internal" href="#preserve-some-exif-data" id="toc-entry-68">Preserve some EXIF data</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#handling-icc-profiles" id="toc-entry-69">Handling ICC Profiles</a></p></li>
- <li><p><a class="reference internal" href="#post-processing-filters" id="toc-entry-70">Post Processing Filters</a></p></li>
- <li><p><a class="reference internal" href="#optimizing-your-website" id="toc-entry-71">Optimizing Your Website</a></p></li>
- <li><p><a class="reference internal" href="#math" id="toc-entry-72">Math</a></p>
- <ul>
- <li><p><a class="reference internal" href="#configuration-1" id="toc-entry-73">Configuration</a></p></li>
- <li><p><a class="reference internal" href="#inline-usage" id="toc-entry-74">Inline usage</a></p></li>
- <li><p><a class="reference internal" href="#display-usage" id="toc-entry-75">Display usage</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#restructuredtext-extensions" id="toc-entry-76">reStructuredText Extensions</a></p>
- <ul>
- <li><p><a class="reference internal" href="#includes" id="toc-entry-77">Includes</a></p></li>
- <li><p><a class="reference internal" href="#media" id="toc-entry-78">Media</a></p></li>
- <li><p><a class="reference internal" href="#youtube" id="toc-entry-79">YouTube</a></p></li>
- <li><p><a class="reference internal" href="#vimeo" id="toc-entry-80">Vimeo</a></p></li>
- <li><p><a class="reference internal" href="#soundcloud" id="toc-entry-81">Soundcloud</a></p></li>
- <li><p><a class="reference internal" href="#code" id="toc-entry-82">Code</a></p></li>
- <li><p><a class="reference internal" href="#listing" id="toc-entry-83">Listing</a></p></li>
- <li><p><a class="reference internal" href="#gist" id="toc-entry-84">Gist</a></p></li>
- <li><p><a class="reference internal" href="#thumbnails" id="toc-entry-85">Thumbnails</a></p></li>
- <li><p><a class="reference internal" href="#chart" id="toc-entry-86">Chart</a></p></li>
- <li><p><a class="reference internal" href="#doc" id="toc-entry-87">Doc</a></p></li>
- <li><p><a class="reference internal" href="#post-list" id="toc-entry-88">Post List</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#importing-your-wordpress-site-into-nikola" id="toc-entry-89">Importing your WordPress site into Nikola</a></p>
- <ul>
- <li><p><a class="reference internal" href="#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>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#using-twitter-cards" id="toc-entry-91">Using Twitter Cards</a></p></li>
- <li><p><a class="reference internal" href="#custom-plugins" id="toc-entry-92">Custom Plugins</a></p></li>
- <li><p><a class="reference internal" href="#getting-extra-plugins" id="toc-entry-93">Getting Extra Plugins</a></p></li>
- <li><p><a class="reference internal" href="#advanced-features" id="toc-entry-94">Advanced Features</a></p>
- <ul>
- <li><p><a class="reference internal" href="#debugging" id="toc-entry-95">Debugging</a></p></li>
- <li><p><a class="reference internal" href="#shell-tab-completion" id="toc-entry-96">Shell Tab Completion</a></p></li>
- </ul>
- </li>
- <li><p><a class="reference internal" href="#license" id="toc-entry-97">License</a></p></li>
- </ul>
- </nav>
- <section id="all-you-need-to-know">
- <h1><a class="toc-backref" href="#toc-entry-1" role="doc-backlink">All You Need to Know</a></h1>
- <p>After you have Nikola <a class="reference external" href="https://getnikola.com/getting-started.html">installed</a>:</p>
- <dl>
- <dt>Create an empty site (with a setup wizard):</dt>
- <dd><p><code class="docutils literal">nikola init mysite</code></p>
- <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>
- <p>The rest of these commands have to be executed inside the new <code class="docutils literal">mysite</code> folder.</p>
- </dd>
- <dt>Create a post:</dt>
- <dd><p><code class="docutils literal">nikola new_post</code></p>
- </dd>
- <dt>Edit the post:</dt>
- <dd><p>The filename should be in the output of the previous command.
- You can also use <code class="docutils literal">nikola new_post <span class="pre">-e</span></code> to open an editor automatically.</p>
- </dd>
- <dt>Build the site:</dt>
- <dd><p><code class="docutils literal">nikola build</code></p>
- </dd>
- <dt>Start the test server and open a browser:</dt>
- <dd><p><code class="docutils literal">nikola serve <span class="pre">-b</span></code></p>
- </dd>
- </dl>
- <p>That should get you going. If you want to know more, this manual will always be here
- for you.</p>
- <p>DON'T READ THIS MANUAL. IF YOU NEED TO READ IT I FAILED, JUST USE THE THING.</p>
- <p>On the other hand, if anything about Nikola is not as obvious as it should be, by all
- means tell me about it :-)</p>
- </section>
- <section id="what-s-nikola-and-what-can-you-do-with-it">
- <h1><a class="toc-backref" href="#toc-entry-2" role="doc-backlink">What's Nikola and what can you do with it?</a></h1>
- <p>Nikola is a static website and blog generator. The very short explanation is
- that it takes some texts you wrote, and uses them to create a folder full
- of HTML files. If you upload that folder to a server, you will have a
- rather full-featured website, done with little effort.</p>
- <p>Its original goal is to create blogs, but it supports most kind of sites, and
- can be used as a CMS, as long as what you present to the user is your own content
- instead of something the user generates.</p>
- <p>Nikola can do:</p>
- <ul class="simple">
- <li><p>A blog (<a class="reference external" href="https://ralsina.me">example</a>)</p></li>
- <li><p>Your company's site</p></li>
- <li><p>Your personal site</p></li>
- <li><p>A software project's site (<a class="reference external" href="https://getnikola.com">example</a>)</p></li>
- <li><p>A book's site</p></li>
- </ul>
- <p>Since Nikola-based sites don't run any code on the server, there is no way to process
- user input in forms.</p>
- <p>Nikola can't do:</p>
- <ul class="simple">
- <li><p>Twitter</p></li>
- <li><p>Facebook</p></li>
- <li><p>An Issue tracker</p></li>
- <li><p>Anything with forms, really (except for <a class="reference internal" href="#comments">comments</a>!)</p></li>
- </ul>
- <p>Keep in mind that "static" doesn't mean <strong>boring</strong>. You can have animations
- or whatever fancy CSS3/HTML5 thingie you like. It only means all that HTML is
- generated already before being uploaded. On the other hand, Nikola sites will
- tend to be content-heavy. What Nikola is good at is at putting what you write
- out there.</p>
- </section>
- <section id="getting-help">
- <h1><a class="toc-backref" href="#toc-entry-3" role="doc-backlink">Getting Help</a></h1>
- <p class="lead"><a class="reference external" href="https://getnikola.com/contact.html">Get help here!</a></p>
- <p>TL;DR:</p>
- <ul class="simple">
- <li><p>You can file bugs at <a class="reference external" href="https://github.com/getnikola/nikola/issues">the issue tracker</a></p></li>
- <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>
- <li><p>You can subscribe to <a class="reference external" href="https://getnikola.com/blog">the Nikola Blog</a></p></li>
- <li><p>You can follow <a class="reference external" href="https://twitter.com/GetNikola">Nikola on Twitter</a></p></li>
- </ul>
- </section>
- <section id="why-static">
- <h1><a class="toc-backref" href="#toc-entry-4" role="doc-backlink">Why Static?</a></h1>
- <p>Most "modern" websites are <em>dynamic</em> in the sense that the contents of the site
- live in a database, and are converted into presentation-ready HTML only when a
- user wants to see the page. That's great. However, it presents some minor issues
- that static site generators try to solve.</p>
- <p>In a static site, the whole site, every page, <em>everything</em>, is created before
- the first user even sees it and uploaded to the server as a simple folder full
- of HTML files (and images, CSS, etc).</p>
- <p>So, let's see some reasons for using static sites:</p>
- <dl>
- <dt>Security</dt>
- <dd><p>Dynamic sites are prone to experience security issues. The solution for that
- is constant vigilance, keeping the software behind the site updated, and
- plain old good luck. The stack of software used to provide a static site,
- like those Nikola generates, is much smaller (Just a web server).</p>
- <p>A smaller software stack implies less security risk.</p>
- </dd>
- <dt>Obsolescence</dt>
- <dd><p>If you create a site using (for example) WordPress, what happens when WordPress
- releases a new version? You have to update your WordPress. That is not optional,
- because of security and support issues. If I release a new version of Nikola, and
- you don't update, <em>nothing</em> happens. You can continue to use the version you
- have now forever, no problems.</p>
- <p>Also, in the longer term, the very foundations of dynamic sites shift. Can you
- still deploy a blog software based on Django 0.96? What happens when your
- host stops supporting the PHP version you rely on? And so on.</p>
- <p>You may say those are long term issues, or that they won't matter for years. Well,
- I believe things should work forever, or as close to it as we can make them.
- Nikola's static output and its input files will work as long as you can install
- Python 3.7 or newer under Linux, Windows, or macOS and can find a server
- that sends files over HTTP. That's probably 10 or 15 years at least.</p>
- <p>Also, static sites are easily handled by the Internet Archive.</p>
- </dd>
- <dt>Cost and Performance</dt>
- <dd><p>On dynamic sites, every time a reader wants a page, a whole lot of database
- queries are made. Then a whole pile of code chews that data, and HTML is
- produced, which is sent to the user. All that requires CPU and memory.</p>
- <p>On a static site, the highly optimized HTTP server reads the file from disk
- (or, if it's a popular file, from disk cache), and sends it to the user. You could
- probably serve a bazillion (technical term) page views from a phone using
- static sites.</p>
- </dd>
- <dt>Lock-in</dt>
- <dd><p>On server-side blog platforms, sometimes you can't export your own data, or
- it's in strange formats you can't use in other services. I have switched
- blogging platforms from Advogato to PyCs to two homebrew systems, to Nikola,
- and have never lost a file, a URL, or a comment. That's because I have <em>always</em>
- had my own data in a format of my choice.</p>
- <p>With Nikola, you own your files, and you can do anything with them.</p>
- </dd>
- </dl>
- </section>
- <section id="components">
- <h1><a class="toc-backref" href="#toc-entry-5" role="doc-backlink">Components</a></h1>
- <p>Nikola provides the following features:</p>
- <ul class="simple">
- <li><p>Blog support, including:</p>
- <ul>
- <li><p>Indexes</p></li>
- <li><p>RSS and Atom feeds</p></li>
- <li><p>Tags and categories, with pages and feeds</p></li>
- <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>
- <li><p>Archives with custom granularity (yearly or monthly)</p></li>
- <li><p><a class="reference internal" href="#comments">Comments</a></p></li>
- </ul>
- </li>
- <li><p>Static pages (not part of the blog)</p></li>
- <li><p><a class="reference internal" href="#math">Math</a> rendering (via MathJax)</p></li>
- <li><p>Custom output paths for generated pages</p></li>
- <li><p>Pretty URLs (without <code class="docutils literal">.html</code>) that don’t need web server support</p></li>
- <li><p>Easy page template customization</p></li>
- <li><p>Internationalization support (my own blog is English and Spanish)</p></li>
- <li><p>Sitemap generation (for search engines)</p></li>
- <li><p>Custom deployment (if it’s a command, you can use it)</p></li>
- <li><p>GitHub Pages deployment</p></li>
- <li><p>Themes, easy appearance customization</p></li>
- <li><p><a class="reference external" href="#supported-input-formats">Multiple input formats</a>, including reStructuredText and Markdown</p></li>
- <li><p>Easy-to-create image galleries</p></li>
- <li><p>Image thumbnail generation</p></li>
- <li><p>Support for displaying source code listings</p></li>
- <li><p>Custom search</p></li>
- <li><p>Asset (CSS/JS) bundling</p></li>
- <li><p>gzip compression (for sending via your web server)</p></li>
- <li><p>Open Graph, Twitter Cards</p></li>
- <li><p>Hyphenation</p></li>
- <li><p>Custom <a class="reference internal" href="#post-processing-filters">post processing filters</a> (eg. for minifying files or better typography)</p></li>
- </ul>
- </section>
- <section id="getting-started">
- <h1><a class="toc-backref" href="#toc-entry-6" role="doc-backlink">Getting Started</a></h1>
- <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>
- </section>
- <section id="creating-a-blog-post">
- <h1><a class="toc-backref" href="#toc-entry-7" role="doc-backlink">Creating a Blog Post</a></h1>
- <aside class="sidebar">
- <p class="sidebar-title">Magic Links</p>
- <p>You will want to do things like "link from one post to another" or "link to an image gallery",
- etc. Sure, you can just figure out the URLs for each thing and use that. Or you can use
- Nikola's special link URLs. Those are done using the syntax <code class="docutils literal"><span class="pre">link://kind/name</span></code> and
- a full list of the included ones is <a class="reference external" href="link://slug/path-handlers">here</a> (BTW, I linked
- to that using <code class="docutils literal"><span class="pre">link://slug/path-handlers</span></code>).</p>
- <p>Note that magic links with spaces won’t work with some input formats (eg.
- reST), so you should use slugs there (eg. <code class="docutils literal"><span class="pre">link://tag/some-tag</span></code> instead of
- <code class="docutils literal"><span class="pre">link://tag/Some</span> Tag</code>)</p>
- </aside>
- <p>To create a new post, the easiest way is to run <code class="docutils literal">nikola new_post</code>. You will
- be asked for a title for your post, and it will tell you where the post's file
- is located.</p>
- <p>By default, that file will contain also some extra information about your post ("the metadata").
- 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
- easier to keep it in a single location.</p>
- <p>The contents of your post have to be written (by default) in <a class="reference external" href="https://docutils.sourceforge.io/">reStructuredText</a>
- but you can use a lot of different markups using the <code class="docutils literal"><span class="pre">-f</span></code> option.</p>
- <p>Currently, Nikola supports reStructuredText, Markdown, Jupyter Notebooks, HTML as input,
- can also use Pandoc for conversion, and has support for BBCode, CreoleWiki, txt2tags, Textile
- and more via plugins — for more details, read the <a class="reference external" href="#multiple-input-formats">input format documentation</a>.
- You can learn reStructuredText syntax with the <a class="reference external" href="https://getnikola.com/quickstart.html">reST quickstart</a>.</p>
- <p>Please note that Nikola does not support encodings other than UTF-8. Make sure
- to convert your input files to that encoding to avoid issues. It will prevent
- bugs, and Nikola will write UTF-8 output anyway.</p>
- <p>You can control what markup compiler is used for each file extension with the <code class="docutils literal">COMPILERS</code>
- option. The default configuration expects them to be placed in <code class="docutils literal">posts</code> but that can be
- changed (see below, the <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code> options)</p>
- <p>This is how it works:</p>
- <pre class="code console"><a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-1"></a><span class="gp">$</span> nikola new_post
- <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-2"></a><span class="go">Creating New Post</span>
- <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-3"></a><span class="go">-----------------</span>
- <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-4"></a>
- <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-5"></a><span class="go">Title: How to make money</span>
- <a name="rest_code_27f80e9a519343b59b7e590691a9d5b9-6"></a><span class="go">Scanning posts....done!</span>
- <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>
- </pre><p>The content of that file is as follows:</p>
- <pre class="code restructuredtext"><a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-1"></a><span class="cp">.. title: How to make money</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-2"></a><span class="cp">.. slug: how-to-make-money</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-3"></a><span class="cp">.. date: 2012-09-15 19:52:05 UTC</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-4"></a><span class="cp">.. tags:</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-5"></a><span class="cp">.. link:</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-6"></a><span class="cp">.. description:</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-7"></a><span class="cp">.. type: text</span>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-8"></a>
- <a name="rest_code_d333d88e8ec84873a87f6e2d428162fe-9"></a>Write your post here.
- </pre><p>You can edit these files with your favorite text editor, and once you are happy
- with the contents, generate the pages using <code class="docutils literal">nikola build</code>.</p>
- <p>The post page is generated by default using the <code class="docutils literal">post.tmpl</code> template, which you can use
- to customize the output. You can also customize paths and the template filename
- itself — see <cite>How does Nikola decide where posts should go?</cite></p>
- <section id="metadata-fields">
- <h2><a class="toc-backref" href="#toc-entry-8" role="doc-backlink">Metadata fields</a></h2>
- <p>Nikola supports many metadata fields in posts. All of them are
- translatable and almost all are optional.</p>
- <section id="basic">
- <h3><a class="toc-backref" href="#toc-entry-9" role="doc-backlink">Basic</a></h3>
- <dl>
- <dt>title</dt>
- <dd><p>Title of the post. Using HTML/math in titles is not supported/recommended.
- If not specified, the file name will be used.</p>
- </dd>
- <dt>slug</dt>
- <dd><p>Slug of the post. Used as the last component of the page URL. We recommend
- and default to using a restricted character set (<code class="docutils literal"><span class="pre">a-z0-9-_</span></code>) because
- other symbols may cause issues in URLs. If not specified, the file name will be used.</p>
- <p>So, if the slug is "the-slug" the page generated would be "the-slug.html" or
- "the-slug/index.html" (if you have the pretty URLs option enabled)</p>
- <p>One special case is setting the slug to "index". This means the page generated
- would be "some_folder/index.html", which means it will be open for the URL
- that ends in "some_folder" or "some_folder/".</p>
- <p>This is useful in some cases, in others may cause conflicts with other pages
- Nikola generates (like blog indexes) and as a side effect it disables
- "pretty URLs" for this page. So use with care.</p>
- </dd>
- <dt>date</dt>
- <dd><p>Date of the post, defaults to now. Multiple date formats are accepted.
- Adding a timezone is recommended. (required for posts)</p>
- </dd>
- <dt>tags</dt>
- <dd><p>Comma-separated tags of the post.</p>
- </dd>
- <dt>status</dt>
- <dd><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>
- </dd>
- <dt>has_math</dt>
- <dd><p>If set to <code class="docutils literal">true</code> or <code class="docutils literal">yes</code>, MathJax resp. KaTeX support is enabled
- for this post.</p>
- </dd>
- <dt>category</dt>
- <dd><p>Like tags, except each post can have only one, and they usually have
- more descriptive names.</p>
- </dd>
- <dt>guid</dt>
- <dd><p>String used as GUID in RSS feeds and as ID in Atom feeds instead of the
- permalink.</p>
- </dd>
- <dt>link</dt>
- <dd><p>Link to original source for content. May be displayed by some themes.</p>
- </dd>
- <dt>description</dt>
- <dd><p>Description of the post. Used in <code class="docutils literal"><meta></code> tags for SEO.</p>
- </dd>
- <dt>type</dt>
- <dd><p>Type of the post. See <a class="reference internal" href="#post-types">Post Types</a> for details. Whatever you set here
- (prepended with <code class="docutils literal">post-</code>) will become a CSS class of the <code class="docutils literal"><article></code>
- 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>
- class)</p>
- </dd>
- </dl>
- </section>
- <section id="extra">
- <h3><a class="toc-backref" href="#toc-entry-10" role="doc-backlink">Extra</a></h3>
- <dl>
- <dt>author</dt>
- <dd><p>Author of the post, will be used in the RSS feed and possibly in the post
- display (theme-dependent)</p>
- </dd>
- <dt>enclosure</dt>
- <dd><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>
- </dd>
- <dt>data</dt>
- <dd><p>Path to an external data file (JSON/YAML/TOML dictionary), relative to <code class="docutils literal">conf.py</code>.
- Its keys are available for templates as <code class="docutils literal"><span class="pre">post.data('key')</span></code>.</p>
- <p>Translated posts can have different values for this field, and the correct one will be
- used.</p>
- <p>See <a class="reference internal" href="#the-global-context-and-data-files">The Global Context and Data files</a> for more details. This is
- especially useful used in combination with <a class="reference internal" href="#shortcodes">shortcodes</a>.</p>
- </dd>
- <dt>filters</dt>
- <dd><p>See the <a class="reference internal" href="#post-processing-filters">Post Processing Filters</a> section.</p>
- </dd>
- <dt>hidetitle</dt>
- <dd><p>Set "True" if you do not want to see the <strong>page</strong> title as a
- heading of the output html file (does not work for posts).</p>
- </dd>
- <dt>hyphenate</dt>
- <dd><p>Set "True" if you want this document to be hyphenated even if you have
- hyphenation disabled by default.</p>
- </dd>
- <dt>nocomments</dt>
- <dd><p>Set to "True" to disable comments.</p>
- </dd>
- <dt>pretty_url</dt>
- <dd><p>Set to "False" to disable pretty URL for this page.</p>
- </dd>
- <dt>previewimage</dt>
- <dd><p>Designate a preview or other representative image path relative to BASE_URL
- for use with Open Graph for posts. Adds the image when sharing on social
- media, feeds, and many other uses.</p>
- <pre class="code restructuredtext"><a name="rest_code_97a673e5affa4cf4b57957e3e858b667-1"></a><span class="cp">.. previewimage: /images/looks_great_on_facebook.png</span>
- </pre><p>If a post has no <cite>previewimage</cite> it will try to use the <cite>DEFAULT_PREVIEW_IMAGE</cite>
- option from the configuration.</p>
- <p>The image can be of any size and dimension (services will crop and adapt)
- but should less than 1 MB and be larger than 300x300 (ideally 600x600).</p>
- <p>This image is displayed by <code class="docutils literal">bootblog4</code> for featured posts (see <a class="reference internal" href="#featured-posts">Featured
- Posts</a> for details).</p>
- </dd>
- <dt>template</dt>
- <dd><p>Change the template used to render this page/post specific page. That
- template needs to either be part of the theme, or be placed in a
- <code class="docutils literal">templates/</code> folder inside your site.</p>
- <pre class="code restructuredtext"><a name="rest_code_b80b58639b8041c3924a6ca547364653-1"></a><span class="cp">.. template: foobar.tmpl</span>
- </pre></dd>
- <dt>updated</dt>
- <dd><p>The last time this post was updated, defaults to the post’s <code class="docutils literal">date</code>
- metadata value. It is not displayed by default in most themes, including
- the defaults — you can use <code class="docutils literal">post.formatted_updated(date_format)</code> (and
- perhaps check <code class="docutils literal">if post.updated != post.date</code>) in your post template to
- show it.</p>
- </dd>
- </dl>
- <p>To add these metadata fields to all new posts by default, you can set the
- variable <code class="docutils literal">ADDITIONAL_METADATA</code> in your configuration. For example, you can
- add the author metadata to all new posts by default, by adding the following
- to your configuration:</p>
- <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>
- <a name="rest_code_50d82e8fa05a410d9742622ce1b51a2f-2"></a> <span class="s1">'author'</span><span class="p">:</span> <span class="s1">'John Doe'</span>
- <a name="rest_code_50d82e8fa05a410d9742622ce1b51a2f-3"></a><span class="p">}</span>
- </pre><dl>
- <dt>url_type</dt>
- <dd><p>Change the URL_TYPE setting for the given page only. Useful for eg. error
- pages which cannot use relative URLs.</p>
- <pre class="code restructuredtext"><a name="rest_code_2854eb3509c24c4bbe597eaaacef8728-1"></a><span class="cp">.. url_type: full_path</span>
- </pre></dd>
- </dl>
- </section>
- </section>
- <section id="metadata-formats">
- <h2><a class="toc-backref" href="#toc-entry-11" role="doc-backlink">Metadata formats</a></h2>
- <p>Metadata can be in different formats.
- Current Nikola versions experimentally supports other metadata formats that make it more compatible with
- other static site generators. The currently supported metadata formats are:</p>
- <ul class="simple">
- <li><p>reST-style comments (<code class="docutils literal">.. name: value</code> — default format)</p></li>
- <li><p>Two-file format (reST-style, YAML, TOML)</p></li>
- <li><p>Jupyter Notebook metadata</p></li>
- <li><p>YAML, between <code class="docutils literal"><span class="pre">---</span></code> (Jekyll, Hugo)</p></li>
- <li><p>TOML, between <code class="docutils literal">+++</code> (Hugo)</p></li>
- <li><p>reST docinfo (Pelican)</p></li>
- <li><p>Markdown metadata extension (Pelican)</p></li>
- <li><p>HTML meta tags (Pelican)</p></li>
- </ul>
- <p>You can add arbitrary meta fields in any format.</p>
- <p>When you create new posts, by default the metadata will be created as reST style comments.
- If you prefer a different format, you can set the <code class="docutils literal">METADATA_FORMAT</code> to one of these values:</p>
- <ul class="simple">
- <li><p><code class="docutils literal">"Nikola"</code>: reST comments, wrapped in a HTML comment if needed (default)</p></li>
- <li><p><code class="docutils literal">"YAML"</code>: YAML wrapped in "---"</p></li>
- <li><p><code class="docutils literal">"TOML"</code>: TOML wrapped in "+++"</p></li>
- <li><p><code class="docutils literal">"Pelican"</code>: Native markdown metadata or reST docinfo fields. Nikola style for other formats.</p></li>
- </ul>
- <section id="rest-style-comments">
- <h3><a class="toc-backref" href="#toc-entry-12" role="doc-backlink">reST-style comments</a></h3>
- <p>The “traditional” and default meta field format is:</p>
- <pre class="code text"><a name="rest_code_f90ce434a9874e66ba5689c7d1bab7ad-1"></a>.. name: value
- </pre><p>If you are not using reStructuredText, make sure the fields are in a HTML comment in output.</p>
- <p>Also, note that this format does not support any multi-line values. Try YAML or reST docinfo if you need those.</p>
- </section>
- <section id="two-file-format">
- <h3><a class="toc-backref" href="#toc-entry-13" role="doc-backlink">Two-file format</a></h3>
- <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>
- <pre class="code text"><a name="rest_code_1022c20cc60e4916ba5a84038643797e-1"></a>.. title: How to make money
- <a name="rest_code_1022c20cc60e4916ba5a84038643797e-2"></a>.. slug: how-to-make-money
- <a name="rest_code_1022c20cc60e4916ba5a84038643797e-3"></a>.. date: 2012-09-15 19:52:05 UTC
- </pre><p>You can also use YAML or TOML metadata inside those (with the appropriate markers).</p>
- </section>
- <section id="jupyter-notebook-metadata">
- <h3><a class="toc-backref" href="#toc-entry-14" role="doc-backlink">Jupyter Notebook metadata</a></h3>
- <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>
- <pre class="code json"><a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-1"></a><span class="p">{</span>
- <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-2"></a> <span class="nt">"nikola"</span><span class="p">:</span> <span class="p">{</span>
- <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>
- <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>
- <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>
- <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-6"></a> <span class="p">}</span>
- <a name="rest_code_9647fc2add0344ac9e8656918e2ea2d4-7"></a><span class="p">}</span>
- </pre></section>
- <section id="yaml-metadata">
- <h3><a class="toc-backref" href="#toc-entry-15" role="doc-backlink">YAML metadata</a></h3>
- <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>
- <pre class="code yaml"><a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-1"></a><span class="nn">---</span>
- <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>
- <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>
- <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>
- <a name="rest_code_f4e6fbfb07d240f18bca1ee54c4bbead-5"></a><span class="nn">---</span>
- </pre></section>
- <section id="toml-metadata">
- <h3><a class="toc-backref" href="#toc-entry-16" role="doc-backlink">TOML metadata</a></h3>
- <p>TOML metadata should be wrapped by a "+++" separator (three plus signs) and in that case, the usual TOML syntax is used:</p>
- <pre class="code yaml"><a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-1"></a><span class="l l-Scalar l-Scalar-Plain">+++</span>
- <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-2"></a><span class="l l-Scalar l-Scalar-Plain">title = "How to make money"</span>
- <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-3"></a><span class="l l-Scalar l-Scalar-Plain">slug = "how-to-make-money"</span>
- <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-4"></a><span class="l l-Scalar l-Scalar-Plain">date = "2012-09-15 19:52:05 UTC"</span>
- <a name="rest_code_c9318f4484674b5ab527be3ebdc1516d-5"></a><span class="l l-Scalar l-Scalar-Plain">+++</span>
- </pre></section>
- <section id="rest-docinfo">
- <h3><a class="toc-backref" href="#toc-entry-17" role="doc-backlink">reST docinfo</a></h3>
- <p>Nikola can extract metadata from reStructuredText docinfo fields and the document itself, too:</p>
- <pre class="code restructuredtext"><a name="rest_code_adc136ef3f8e4caf9316c947f102584d-1"></a><span class="gh">How to make money</span>
- <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-2"></a><span class="gh">=================</span>
- <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-3"></a>
- <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-4"></a><span class="nc">:slug:</span> how-to-make-money
- <a name="rest_code_adc136ef3f8e4caf9316c947f102584d-5"></a><span class="nc">:date:</span> 2012-09-15 19:52:05 UTC
- </pre><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>,
- and Nikola will hide the docinfo fields in the output if you set
- <code class="docutils literal">HIDE_REST_DOCINFO = True</code>.</p>
- <aside class="admonition note">
- <p class="admonition-title">Note</p>
- <p>Keys are converted to lowercase automatically.</p>
- <p>This setting also means that the first heading in a post will be removed
- and considered a title. This is important if you’re mixing metadata
- styles. This can be solved by putting a reST comment before your title.</p>
- </aside>
- </section>
- <section id="pelican-markdown-metadata">
- <h3><a class="toc-backref" href="#toc-entry-18" role="doc-backlink">Pelican/Markdown metadata</a></h3>
- <p>Markdown Metadata (Pelican-style) only works in Markdown files, and requires the <code class="docutils literal">markdown.extensions.meta</code> extension
- (see <a class="reference external" href="#markdown">MARKDOWN_EXTENSIONS</a>). The exact format is described in
- the <a class="reference external" href="https://python-markdown.github.io/extensions/meta_data/">markdown metadata extension docs.</a></p>
- <pre class="code text"><a name="rest_code_7439c987f2344616a3b2cbb1a6cebfa9-1"></a>title: How to make money
- <a name="rest_code_7439c987f2344616a3b2cbb1a6cebfa9-2"></a>slug: how-to-make-money
- <a name="rest_code_7439c987f2344616a3b2cbb1a6cebfa9-3"></a>date: 2012-09-15 19:52:05 UTC
- </pre><p>Note that keys are converted to lowercase automatically.</p>
- </section>
- <section id="html-meta-tags">
- <h3><a class="toc-backref" href="#toc-entry-19" role="doc-backlink">HTML meta tags</a></h3>
- <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.
- Following Pelican's behaviour, tags can be put in a "tags" meta tag or in a "keywords" meta tag. Example:</p>
- <pre class="code html"><a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-1"></a><span class="p"><</span><span class="nt">html</span><span class="p">></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-2"></a> <span class="p"><</span><span class="nt">head</span><span class="p">></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-3"></a> <span class="p"><</span><span class="nt">title</span><span class="p">></span>My super title<span class="p"></</span><span class="nt">title</span><span class="p">></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-4"></a> <span class="p"><</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">/></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-5"></a> <span class="p"><</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">/></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-6"></a> <span class="p"><</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">/></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-7"></a> <span class="p"><</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">/></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-8"></a> <span class="p"><</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">/></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-9"></a> <span class="p"><</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">/></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-10"></a> <span class="p"></</span><span class="nt">head</span><span class="p">></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-11"></a> <span class="p"><</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-12"></a> This is the content of my super blog post.
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-13"></a> <span class="p"></</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_4498a64614fc41caa8f76bb21d7c3d45-14"></a><span class="p"></</span><span class="nt">html</span><span class="p">></span>
- </pre></section>
- <section id="mapping-metadata-from-other-formats">
- <h3><a class="toc-backref" href="#toc-entry-20" role="doc-backlink">Mapping metadata from other formats</a></h3>
- <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>
- <p>For Pelican, use:</p>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_e726dc97319445be881e170a226ccf89-5"></a><span class="p">}</span>
- </pre><p>For Hugo, use:</p>
- <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>
- <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>
- <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>
- <a name="rest_code_fd7d31032d31435784f80d60617c05a5-4"></a><span class="p">}</span>
- </pre><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>
- <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>
- <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>
- <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 -> str</span>
- <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-3"></a> <span class="s2">"nikola"</span><span class="p">:</span> <span class="p">{</span>
- <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 -> list</span>
- <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>
- <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-6"></a> <span class="p">}</span>
- <a name="rest_code_37ab99d321f34e6a81a1c6429c22ebcb-7"></a><span class="p">}</span>
- </pre></section>
- </section>
- <section id="multilingual-posts">
- <h2><a class="toc-backref" href="#toc-entry-21" role="doc-backlink">Multilingual posts</a></h2>
- <p>If you are writing a multilingual site, you can also create a per-language
- 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).
- This one can replace metadata of the default language, for example:</p>
- <ul class="simple">
- <li><p>The translated title for the post or page</p></li>
- <li><p>A translated version of the page name</p></li>
- </ul>
- <p>The pattern used for finding translations is controlled by the
- TRANSLATIONS_PATTERN variable in your configuration file.</p>
- <p>The default is to put the language code before the file extension,
- so the German translation of <code class="docutils literal">some_file.rst</code> should be named
- <code class="docutils literal">some_file.de.rst</code>. This is because the TRANSLATIONS_PATTERN variable is by
- default set to:</p>
- <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>
- </pre><aside class="admonition admonition-considered-languages">
- <p class="admonition-title">Considered languages</p>
- <p>Nikola will only look for translation of input files for languages
- specified in the TRANSLATIONS variable.</p>
- </aside>
- <p>In case you translate your posts, you might also want to adjust various
- other settings so that the generated URLs match the translation. You can
- find most places in <code class="docutils literal">conf.py</code> by searching for <code class="docutils literal">(translatable)</code>. For example,
- 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>
- 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
- how to adjust the URLs for subsequent pages for indexes (search for
- <code class="docutils literal">INDEXES_PRETTY_PAGE_URL</code>).</p>
- <p>Nikola supports multiple languages for a post (we have almost 50 translations!). If you wish to
- 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>
- </section>
- <section id="how-does-nikola-decide-where-posts-should-go">
- <h2><a class="toc-backref" href="#toc-entry-22" role="doc-backlink">How does Nikola decide where posts should go?</a></h2>
- <p>The place where the post will be placed by <code class="docutils literal">new_post</code> (the first one that
- matches the given format) and the final post destination (the first one that
- matches a given file) is based on the <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code> configuration
- options. The exact mechanism is explained above the config options in the
- <code class="docutils literal">conf.py</code> file, and also reproduced below:</p>
- <pre class="code python"><a name="rest_code_6843e34d56cb46c7baae4db401bbab10-1"></a><span class="c1"># POSTS and PAGES contains (wildcard, destination, template) tuples.</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-2"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-3"></a><span class="c1"># The wildcard is used to generate a list of post source files</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-4"></a><span class="c1"># (whatever/thing.rst, for example).</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-5"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-6"></a><span class="c1"># That fragment could have an associated metadata file (whatever/thing.meta),</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-7"></a><span class="c1"># and optionally translated files (example for Spanish, with code "es"):</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-8"></a><span class="c1"># whatever/thing.es.rst and whatever/thing.es.meta</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-9"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-10"></a><span class="c1"># This assumes you use the default TRANSLATIONS_PATTERN.</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-11"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-12"></a><span class="c1"># From those files, a set of HTML fragment files will be generated:</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-13"></a><span class="c1"># cache/whatever/thing.html (and maybe cache/whatever/thing.html.es)</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-14"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-15"></a><span class="c1"># These files are combined with the template to produce rendered</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-16"></a><span class="c1"># pages, which will be placed at</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-17"></a><span class="c1"># output/TRANSLATIONS[lang]/destination/pagename.html</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-18"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-19"></a><span class="c1"># where "pagename" is the "slug" specified in the metadata file.</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-20"></a><span class="c1"># The page might also be placed in /destination/pagename/index.html</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-21"></a><span class="c1"># if PRETTY_URLS are enabled.</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-22"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-23"></a><span class="c1"># The difference between POSTS and PAGES is that POSTS are added</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-24"></a><span class="c1"># to feeds, indexes, tag lists and archives and are considered part</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-25"></a><span class="c1"># of a blog, while PAGES are just independent HTML pages.</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-26"></a><span class="c1">#</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-27"></a><span class="c1"># Finally, note that destination can be translated, i.e. you can</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-28"></a><span class="c1"># specify a different translation folder per language. Example:</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-29"></a><span class="c1"># PAGES = (</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-30"></a><span class="c1"># ("pages/*.rst", {"en": "pages", "de": "seiten"}, "page.tmpl"),</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-31"></a><span class="c1"># ("pages/*.md", {"en": "pages", "de": "seiten"}, "page.tmpl"),</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-32"></a><span class="c1"># )</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-33"></a>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-34"></a><span class="n">POSTS</span> <span class="o">=</span> <span class="p">(</span>
- <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>
- <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>
- <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>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-38"></a><span class="p">)</span>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-39"></a><span class="n">PAGES</span> <span class="o">=</span> <span class="p">(</span>
- <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>
- <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>
- <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>
- <a name="rest_code_6843e34d56cb46c7baae4db401bbab10-43"></a><span class="p">)</span>
- </pre><aside class="admonition admonition-posts-and-pages-are-not-flat">
- <p class="admonition-title">POSTS and PAGES are not flat!</p>
- <p>Even if the syntax may suggest you can't, you can create any directory structure you want
- inside <code class="docutils literal">posts/</code> or <code class="docutils literal">pages/</code> and it will be reflected in the output. For example,
- <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>
- <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>
- </aside>
- <aside class="admonition warning">
- <p class="admonition-title">Warning</p>
- <p>Removing the <code class="docutils literal">.rst</code> entries is not recommended. Some features (eg.
- shortcodes) may not work properly if you do that.</p>
- </aside>
- </section>
- <section id="the-new-post-command">
- <h2><a class="toc-backref" href="#toc-entry-23" role="doc-backlink">The <code class="docutils literal">new_post</code> command</a></h2>
- <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
- supplied) that ends with the extension of your desired markup format (as
- 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
- written into. If no such entry can be found, the post won’t be created.</p>
- <p>The <code class="docutils literal">new_post</code> command supports some options:</p>
- <pre class="code text"><a name="rest_code_9782f0650e3444fd9faf1a32898ca329-1"></a>$ nikola help new_post
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-2"></a>Purpose: create a new blog post or site page
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-3"></a>Usage: nikola new_post [options] [path]
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-4"></a>
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-5"></a>Options:
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-6"></a> -p, --page Create a page instead of a blog post. (see also: `nikola new_page`)
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-7"></a> -t ARG, --title=ARG Title for the post.
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-8"></a> -a ARG, --author=ARG Author of the post.
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-9"></a> --tags=ARG Comma-separated tags for the post.
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-10"></a> -1 Create the post with embedded metadata (single file format)
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-11"></a> -2 Create the post with separate metadata (two file format)
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-12"></a> -e Open the post (and meta file, if any) in $EDITOR after creation.
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-13"></a> -f ARG, --format=ARG Markup format for the post (use --available-formats for list)
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-14"></a> -F, --available-formats List all available input formats
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-15"></a> -s Schedule the post based on recurrence rule
- <a name="rest_code_9782f0650e3444fd9faf1a32898ca329-16"></a> -i ARG, --import=ARG Import an existing file instead of creating a placeholder
- <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)
- </pre><p>The optional <code class="docutils literal">path</code> parameter tells Nikola exactly where to put it instead of guessing from your config.
- 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
- "foo" as its slug. You can also provide a directory name, in which case Nikola
- will append the file name for you (generated from title).</p>
- <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
- similar directory structures. It can be enabled on a per-post basis, or you can
- use it for every post if you set <code class="docutils literal">NEW_POST_DATE_PATH = True</code> in conf.py.</p>
- <pre class="code python"><a name="rest_code_c080bce44b294cb3be1a350c765176a7-1"></a><span class="c1"># Use date-based path when creating posts?</span>
- <a name="rest_code_c080bce44b294cb3be1a350c765176a7-2"></a><span class="c1"># Can be enabled on a per-post basis with `nikola new_post -d`.</span>
- <a name="rest_code_c080bce44b294cb3be1a350c765176a7-3"></a><span class="c1"># NEW_POST_DATE_PATH = False</span>
- <a name="rest_code_c080bce44b294cb3be1a350c765176a7-4"></a>
- <a name="rest_code_c080bce44b294cb3be1a350c765176a7-5"></a><span class="c1"># What format to use when creating posts with date paths?</span>
- <a name="rest_code_c080bce44b294cb3be1a350c765176a7-6"></a><span class="c1"># Default is '%Y/%m/%d', other possibilities include '%Y' or '%Y/%m'.</span>
- <a name="rest_code_c080bce44b294cb3be1a350c765176a7-7"></a><span class="c1"># NEW_POST_DATE_PATH_FORMAT = '%Y/%m/%d'</span>
- </pre></section>
- <section id="teasers">
- <h2><a class="toc-backref" href="#toc-entry-24" role="doc-backlink">Teasers</a></h2>
- <p>You may not want to show the complete content of your posts either on your
- index page or in RSS feeds, but to display instead only the beginning of them.</p>
- <p>If it's the case, you only need to add a "magical comment" <code class="docutils literal">TEASER_END</code> or
- <code class="docutils literal">END_TEASER</code> in your post.</p>
- <p>In reStructuredText:</p>
- <pre class="code restructuredtext"><a name="rest_code_796ffc3896b74430bde6bfbf2cbc40db-1"></a><span class="cp">.. TEASER_END</span>
- </pre><p>In Markdown (or basically, the resulting HTML of any format):</p>
- <pre class="code html"><a name="rest_code_788bd8bb39c1481f81629f603ec19247-1"></a><span class="c"><!-- TEASER_END --></span>
- </pre><p>By default all your RSS feeds will be shortened (they'll contain only teasers)
- whereas your index page will still show complete posts. You can change
- this behavior with your <code class="docutils literal">conf.py</code>: <code class="docutils literal">INDEX_TEASERS</code> defines whether index
- page should display the whole contents or only teasers. <code class="docutils literal">FEED_TEASERS</code>
- works the same way for your Atom and RSS feeds.</p>
- <p>By default, teasers will include a "read more" link at the end. If you want to
- change that text, you can use a custom teaser:</p>
- <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>
- </pre><p>You can override the default value for <code class="docutils literal">TEASER_END</code> in <code class="docutils literal">conf.py</code> — for
- example, the following example will work for <code class="docutils literal">.. more</code>, and will be
- compatible with both WordPress and Nikola posts:</p>
- <pre class="code python"><a name="rest_code_4169f76ff18044958b6007a3e59afadc-1"></a><span class="kn">import</span> <span class="nn">re</span>
- <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">'<!--\s*(more|TEASER_END|END_TEASER)(:(.+))?\s*-->'</span><span class="p">,</span> <span class="n">re</span><span class="o">.</span><span class="n">IGNORECASE</span><span class="p">)</span>
- </pre><p>Or you can completely customize the link using the <code class="docutils literal">READ_MORE_LINK</code> option.</p>
- <pre class="code python"><a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-1"></a><span class="c1"># A HTML fragment with the Read more... link.</span>
- <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-2"></a><span class="c1"># The following tags exist and are replaced for you:</span>
- <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-3"></a><span class="c1"># {link} A link to the full post page.</span>
- <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-4"></a><span class="c1"># {read_more} The string “Read more” in the current language.</span>
- <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-5"></a><span class="c1"># {{ A literal { (U+007B LEFT CURLY BRACKET)</span>
- <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-6"></a><span class="c1"># }} A literal } (U+007D RIGHT CURLY BRACKET)</span>
- <a name="rest_code_30a1f62bce1e4a7da467b6067de5e70f-7"></a><span class="c1"># READ_MORE_LINK = '<p class="more"><a href="{link}">{read_more}…</a></p>'</span>
- </pre></section>
- <section id="drafts">
- <h2><a class="toc-backref" href="#toc-entry-25" role="doc-backlink">Drafts</a></h2>
- <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
- in indexes and feeds. It <em>will</em> be compiled, and if you deploy it it <em>will</em> be made
- available, so use with care. If you wish your drafts to be not available in your
- deployed site, you can set <code class="docutils literal">DEPLOY_DRAFTS = False</code> in your configuration. This will
- not work if you include <code class="docutils literal">nikola build</code> in your <code class="docutils literal">DEPLOY_COMMANDS</code>, as the
- option removes the draft posts before any <code class="docutils literal">DEPLOY_COMMANDS</code> are run.</p>
- <p>Also if a post has a date in the future, it will not be shown in indexes until
- you rebuild after that date. This behavior can be disabled by setting
- <code class="docutils literal">FUTURE_IS_NOW = True</code> in your configuration, which will make future posts be
- published immediately. Posts dated in the future are <em>not</em> deployed by default
- (when <code class="docutils literal">FUTURE_IS_NOW = False</code>). To make future posts available in the
- deployed site, you can set <code class="docutils literal">DEPLOY_FUTURE = True</code> in your configuration.
- Generally, you want FUTURE_IS_NOW and DEPLOY_FUTURE to be the same value.</p>
- </section>
- <section id="private-posts">
- <h2><a class="toc-backref" href="#toc-entry-26" role="doc-backlink">Private Posts</a></h2>
- <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
- in indexes and feeds. It <em>will</em> be compiled, and if you deploy it it <em>will</em> be made
- available, so it will not generate 404s for people who had linked to it.</p>
- </section>
- <section id="featured-posts">
- <h2><a class="toc-backref" href="#toc-entry-27" role="doc-backlink">Featured Posts</a></h2>
- <p>Some themes, <code class="docutils literal">bootblog4</code> in particular, support featured posts. To mark a
- post as featured, simply set the <code class="docutils literal">status</code> meta field to <code class="docutils literal">featured</code>. All
- featured posts are available in index templates in a <code class="docutils literal">featured</code>
- list, but only if this is the main blog index.</p>
- <p>For bootblog4, you can display up to three posts as featured: one can be shown
- in a large gray box (jumbotron), and two more can appear in small white
- cards. In order to enable this feature, you need to add <code class="docutils literal">THEME_CONFIG</code> to
- your configuration, and set it up properly:</p>
- <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>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-2"></a> <span class="n">DEFAULT_LANG</span><span class="p">:</span> <span class="p">{</span>
- <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>
- <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>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-5"></a> <span class="c1"># Show the first (remaining) two featured posts in small boxes.</span>
- <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>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-7"></a> <span class="c1"># Show featured posts on mobile.</span>
- <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>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-9"></a> <span class="c1"># Show image in `featured_large` on mobile.</span>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-10"></a> <span class="c1"># `featured_small` displays them only on desktop.</span>
- <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>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-12"></a> <span class="c1"># Strip HTML from featured post text.</span>
- <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>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-14"></a> <span class="c1"># Contents of the sidebar, If empty, the sidebar is not displayed.</span>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-15"></a> <span class="s1">'sidebar'</span><span class="p">:</span> <span class="s1">''</span>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-16"></a> <span class="p">}</span>
- <a name="rest_code_cb5881d52ac94a3d88003a9ac15b878b-17"></a><span class="p">}</span>
- </pre><p>You can pick betweeen (up to) 1, 2, or 3 featured posts. You can mix
- <code class="docutils literal">featured_large</code> and <code class="docutils literal">featured_small</code>, rest assured that Nikola will always
- display the latest posts no matter what setup you choose. If only one posts
- qualifies for the small cards, one card taking up all the width will appear.</p>
- <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>
- <p>Note that, due to space constraints, only the large box may show the image on
- mobile, below the text (this behavior can be disbled). Small boxes never
- display images on mobile. In particular: <code class="docutils literal">xs</code> and <code class="docutils literal">sm</code> display only the
- large image, and only if configured; <code class="docutils literal">md</code> displays only the large image,
- <code class="docutils literal">lg</code> displays all three images.</p>
- <p>The boxes display only the teaser. We recommend keeping it short so
- you don’t get an ugly scrollbar.</p>
- <p>Finally, here’s an example (you’ll need to imagine a scrollbar in the right box
- yourself):</p>
- <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>
- </section>
- <section id="queuing-posts">
- <h2><a class="toc-backref" href="#toc-entry-28" role="doc-backlink">Queuing Posts</a></h2>
- <p>Some blogs tend to have new posts based on a schedule (for example,
- every Mon, Wed, Fri) but the blog authors don't like to manually
- schedule their posts. You can schedule your blog posts based on a
- rule, by specifying a rule in the <code class="docutils literal">SCHEDULE_RULE</code> in your
- configuration. You can either post specific blog posts according to
- 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>
- command or post all new posts according to this schedule by setting
- <code class="docutils literal">SCHEDULE_ALL = True</code> in your configuration. (Note: This feature
- requires that the <code class="docutils literal">FUTURE_IS_NOW</code> setting is set to <code class="docutils literal">False</code>)</p>
- <p>For example, if you would like to schedule your posts to be on every
- Monday, Wednesday and Friday at 7am, add the following
- <code class="docutils literal">SCHEDULE_RULE</code> to your configuration:</p>
- <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>
- </pre><p>For more details on how to specify a recurrence rule, look at the
- <a class="reference external" href="https://www.kanzaki.com/docs/ical/rrule.html">iCal specification</a>.
- Or if you are scared of this format, many calendaring applications (eg. Google
- Calendar) offer iCal exports, so you can copy-paste the repeat rule from a
- generated iCal (<code class="docutils literal">.ics</code>) file (which is a human-readable text file).</p>
- <p>Say, you get a free Sunday, and want to write a flurry of new posts,
- or at least posts for the rest of the week, you would run the
- <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
- you want:</p>
- <pre class="code console"><a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-1"></a><span class="gp">$</span> nikola new_post --schedule
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-2"></a><span class="gp">#</span> Creates a new post to be posted on Monday, 7am.
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-3"></a><span class="gp">$</span> nikola new_post -s
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-4"></a><span class="gp">#</span> Creates a new post to be posted on Wednesday, 7am.
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-5"></a><span class="gp">$</span> nikola new_post -s
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-6"></a><span class="gp">#</span> Creates a new post to be posted on Friday, 7am.
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-7"></a><span class="go">.</span>
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-8"></a><span class="go">.</span>
- <a name="rest_code_6047b3534ea34d4aa3940809bb8419a5-9"></a><span class="go">.</span>
- </pre><p>All these posts get queued up according to your schedule, but note
- that you will anyway need to build and deploy your site for the posts
- to appear online. You can have a cron job that does this regularly.</p>
- </section>
- <section id="post-types">
- <h2><a class="toc-backref" href="#toc-entry-29" role="doc-backlink">Post Types</a></h2>
- <p>Nikola supports specifying post types, just like Tumblr does. Post
- types affect the look of your posts, by adding a <code class="docutils literal"><span class="pre">post-YOURINPUTHERE</span></code>
- CSS class to the post. Each post can have one and exactly one type. Nikola
- styles the following types in the default themes:</p>
- <table class="table table-bordered">
- <thead>
- <tr><th class="head"><p>Name(s)</p></th>
- <th class="head"><p>Description</p></th>
- <th class="head"><p>Styling</p></th>
- </tr>
- </thead>
- <tbody>
- <tr><td><p>text</p></td>
- <td><p>plain text — default value</p></td>
- <td><p>standard</p></td>
- </tr>
- <tr><td><p>micro</p></td>
- <td><p>“small” (short) posts</p></td>
- <td><p>big serif font</p></td>
- </tr>
- </tbody>
- </table>
- </section>
- <section id="indexes">
- <h2><a class="toc-backref" href="#toc-entry-30" role="doc-backlink">Indexes</a></h2>
- <p>All your posts that are not drafts, private or dated in the future, will be
- shown in indexes.</p>
- <section id="settings">
- <h3><a class="toc-backref" href="#toc-entry-31" role="doc-backlink">Settings</a></h3>
- <p>Indexes are put in the <code class="docutils literal">INDEX_PATH</code> directory, which defaults to an empty
- string (site root). The “main” index is <code class="docutils literal">index.html</code>, and all the further
- indexes are <code class="docutils literal"><span class="pre">index-*.html</span></code>, respectively.</p>
- <p>By default, 10 posts are displayed on an index page. This can be changed with
- <code class="docutils literal">INDEX_DISPLAY_POST_COUNT</code>. Indexes can show full posts or just the teasers,
- as controlled by the <code class="docutils literal">INDEX_TEASERS</code> setting (defaults to <code class="docutils literal">False</code>).</p>
- <p>Titles of the pages can be controlled by using <code class="docutils literal">INDEXES_TITLES</code>,
- <code class="docutils literal">INDEXES_PAGES</code> and <code class="docutils literal">INDEXES_PAGES_MAIN</code> settings.</p>
- <p>Categories and tags use simple lists by default that show only titles and
- dates; however, you can switch them to full indexes by using
- <code class="docutils literal">CATEGORY_PAGES_ARE_INDEXES</code> and <code class="docutils literal">TAG_PAGES_ARE_INDEXES</code>, respectively.</p>
- <p>Something similar happens with authors. To use full indexes in authors, set
- <code class="docutils literal">AUTHOR_PAGES_ARE_INDEXES</code> to <code class="docutils literal">True</code>.</p>
- </section>
- <section id="static-indexes">
- <h3><a class="toc-backref" href="#toc-entry-32" role="doc-backlink">Static indexes</a></h3>
- <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
- the oldest posts, and the newest posts past the first 10 are in
- <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
- 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
- rebuilt (the others remain unchanged). The page that appears when you click
- <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
- posts</strong> if there are not enough posts to fill up all pages.</p>
- <p>This can be disabled by setting <code class="docutils literal">INDEXES_STATIC</code> to <code class="docutils literal">False</code>. In that mode,
- <code class="docutils literal"><span class="pre">index-1.html</span></code> contains all the newest posts past the first 10 and will
- always contain 10 posts (unless you have less than 20). The last page,
- <code class="docutils literal"><span class="pre">index-N.html</span></code>, contains the oldest posts, and might contain less than 10
- posts. This is how many blog engines and CMSes behave. Note that this will
- lead to rebuilding all index pages, which might be a problem for larger blogs
- (with a lot of index pages).</p>
- </section>
- </section>
- <section id="post-taxonomy">
- <h2><a class="toc-backref" href="#toc-entry-33" role="doc-backlink">Post taxonomy</a></h2>
- <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>
- <section id="tags">
- <h3><a class="toc-backref" href="#toc-entry-34" role="doc-backlink">Tags</a></h3>
- <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>
- <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>
- <pre class="code text"><a name="rest_code_1fd858ac735b4e729c0d0c4ca1acda15-1"></a>ERROR: Nikola: You have tags that are too similar: Nikola and nikola
- <a name="rest_code_1fd858ac735b4e729c0d0c4ca1acda15-2"></a>ERROR: Nikola: Tag Nikola is used in: posts/second-post.rst
- <a name="rest_code_1fd858ac735b4e729c0d0c4ca1acda15-3"></a>ERROR: Nikola: Tag nikola is used in: posts/1.rst
- </pre><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>
- </section>
- <section id="categories">
- <h3><a class="toc-backref" href="#toc-entry-35" role="doc-backlink">Categories</a></h3>
- <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>
- <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>
- <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>
- </section>
- <section id="configuring-tags-and-categories">
- <h3><a class="toc-backref" href="#toc-entry-36" role="doc-backlink">Configuring tags and categories</a></h3>
- <p>There are multiple configuration variables dedicated to each of the two taxonomies. You can set:</p>
- <ul class="simple">
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <li><p><code class="docutils literal">CATEGORY_DESTPATH_FIRST_DIRECTORY</code> to only use the first directory name for the defaulted category</p></li>
- <li><p><code class="docutils literal">CATEGORY_DESTPATH_NAMES</code> to specify friendly names for defaulted categories</p></li>
- <li><p><code class="docutils literal">CATEGORY_PAGES_FOLLOW_DESTPATH</code> to put category pages next to their related posts (via destpath)</p></li>
- </ul>
- </section>
- </section>
- <section id="what-if-i-dont-want-a-blog">
- <h2><a class="toc-backref" href="#toc-entry-37" role="doc-backlink">What if I don’t want a blog?</a></h2>
- <p>If you want a static site that does not have any blog-related elements, see our
- <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>
- </section>
- </section>
- <section id="creating-a-page">
- <h1><a class="toc-backref" href="#toc-entry-38" role="doc-backlink">Creating a Page</a></h1>
- <p>Pages are the same as posts, except that:</p>
- <ul class="simple">
- <li><p>They are not added to the front page</p></li>
- <li><p>They don't appear on the RSS feed</p></li>
- <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>
- </ul>
- <p>The default configuration expects the page's metadata and text files to be on the
- <code class="docutils literal">pages</code> folder, but that can be changed (see <code class="docutils literal">PAGES</code> option above).</p>
- <p>You can create the page's files manually or use the <code class="docutils literal">new_post</code> command
- with the <code class="docutils literal"><span class="pre">-p</span></code> option, which will place the files in the folder that
- has <code class="docutils literal">use_in_feed</code> set to False.</p>
- <p>In some places (including default directories and templates), pages are called
- <em>stories</em> for historic reasons. Both are synonyms for the same thing: pages
- that are not blog posts.</p>
- </section>
- <section id="supported-input-formats">
- <h1><a class="toc-backref" href="#toc-entry-39" role="doc-backlink">Supported input formats</a></h1>
- <p>Nikola supports multiple input formats. Out of the box, we have compilers available for:</p>
- <ul class="simple">
- <li><p>reStructuredText (default and pre-configured)</p></li>
- <li><p><a class="reference internal" href="#markdown">Markdown</a> (pre-configured since v7.8.7)</p></li>
- <li><p><a class="reference internal" href="#jupyter-notebook">Jupyter Notebook</a></p></li>
- <li><p><a class="reference internal" href="#html">HTML</a></p></li>
- <li><p><a class="reference internal" href="#php">PHP</a></p></li>
- <li><p>anything <a class="reference internal" href="#pandoc">Pandoc</a> supports (including Textile, DocBook, LaTeX, MediaWiki,
- TWiki, OPML, Emacs Org-Mode, txt2tags, Microsoft Word .docx, EPUB, Haddock markup)</p></li>
- </ul>
- <p>Plus, we have specialized compilers in the Plugins Index for:</p>
- <ul class="simple">
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#asciidoc">AsciiDoc</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#bbcode">BBCode</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#commonmark">CommonMark</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#irclogs">IRC logs</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#markmin">Markmin</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#mediawiki">MediaWiki (smc.mw)</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#misaka">Misaka</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#odt">ODT</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#orgmode">Emacs Org-Mode</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#rest_html5">reST with HTML 5 output</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#textile">Textile</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#txt2tags">txt2tags</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#wiki">CreoleWiki</a></p></li>
- <li><p><a class="reference external" href="https://plugins.getnikola.com/#wordpress_compiler">WordPress posts</a></p></li>
- </ul>
- <p>To write posts in a different format, you need to configure the compiler and
- 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
- new_post <span class="pre">-f</span> markdown</code>. The default compiler used is the first entry in POSTS
- or PAGES.</p>
- <section id="configuring-other-input-formats">
- <h2><a class="toc-backref" href="#toc-entry-40" role="doc-backlink">Configuring other input formats</a></h2>
- <p>In order to use input formats other than reStructuredText, you need some extra
- setup.</p>
- <ol class="arabic simple">
- <li><p>Make sure you have the compiler for the input format you want. Some
- input formats are supported out-of-the-box, but others must be installed from
- the Plugins repository. You may also need some extra dependencies. You
- will get helpful errors if you try to build when missing something.</p></li>
- <li><p>You must ensure the compiler and your desired input file extension is included
- in the <code class="docutils literal">COMPILERS</code> dict and does not conflict with any other format. This
- is extremely important for the pandoc compiler.</p></li>
- <li><p>Finally, you must configure the <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code> tuples. Follow the
- instructions and the format set by pre-existing entries. Make sure to use
- the same extension as is set in <code class="docutils literal">COMPILERS</code> and configure the outputs
- properly.</p></li>
- </ol>
- <section id="markdown">
- <h3><a class="toc-backref" href="#toc-entry-41" role="doc-backlink">Markdown</a></h3>
- <p>To use Markdown in your posts/pages, make sure <code class="docutils literal">markdown</code> is in your
- <code class="docutils literal">COMPILERS</code> and that at least one of your desired extensions is defined in
- <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code>.</p>
- <p>You can use Python-Markdown extensions by setting the <code class="docutils literal">MARKDOWN_EXTENSIONS</code>
- config option:</p>
- <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>
- </pre><p>Nikola comes with some Markdown Extensions built-in and enabled by default,
- namely a gist directive, a podcast directive, and <code class="docutils literal">~~strikethrough~~</code> support.</p>
- </section>
- <section id="jupyter-notebook">
- <h3><a class="toc-backref" href="#toc-entry-42" role="doc-backlink">Jupyter Notebook</a></h3>
- <p>To use Jupyter Notebooks as posts/pages, make sure <code class="docutils literal">ipynb</code> is in your
- <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
- <code class="docutils literal">PAGES</code>.</p>
- <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.
- It defaults to Python in the version used by Nikola if not specified.</p>
- <p>Jupyter Notebooks are also supported in stand-alone listings, if Jupyter
- support is enabled site-wide. You must have something for <code class="docutils literal">.ipynb</code> in POSTS
- or PAGES for the feature to work.</p>
- </section>
- <section id="html">
- <h3><a class="toc-backref" href="#toc-entry-43" role="doc-backlink">HTML</a></h3>
- <p>To use plain HTML in your posts/pages, make sure <code class="docutils literal">html</code> is in your
- <code class="docutils literal">COMPILERS</code>
- 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>
- </section>
- <section id="php">
- <h3><a class="toc-backref" href="#toc-entry-44" role="doc-backlink">PHP</a></h3>
- <p>There are two ways of using PHP within Nikola:</p>
- <ol class="arabic simple">
- <li><p>To use PHP in your posts/pages (inside your site, with the theme and
- 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>
- extension is defined in <code class="docutils literal">POSTS</code> and <code class="docutils literal">PAGES</code>.</p></li>
- <li><p>To use PHP as standalone files (without any modifications), put them in
- <code class="docutils literal">files/</code> (or whatever <code class="docutils literal">FILES_FOLDERS</code> is configured to).</p></li>
- </ol>
- </section>
- <section id="pandoc">
- <h3><a class="toc-backref" href="#toc-entry-45" role="doc-backlink">Pandoc</a></h3>
- <p>To use Pandoc, you must uncomment the entry in <code class="docutils literal">COMPILERS</code> and set the
- extensions list to your desired extensions while also removing them from their
- original compilers. The input format is inferred from the extension by Pandoc.</p>
- <p>Using Pandoc for reStructuredText, Markdown and other input formats that have a
- standalone Nikola plugin is <strong>not recommended</strong> as it disables plugins and
- extensions that are usually provided by Nikola.</p>
- </section>
- </section>
- </section>
- <section id="shortcodes">
- <h1><a class="toc-backref" href="#toc-entry-46" role="doc-backlink">Shortcodes</a></h1>
- <p>This feature is "inspired" (copied wholesale) from <a class="reference external" href="https://gohugo.io/extras/shortcodes/">Hugo</a> so I will
- steal part of their docs too.</p>
- <p>A shortcode is a simple snippet inside a content file that Nikola will render using a predefined template or
- custom code from a plugin.</p>
- <p>To use them from plugins, please see <a class="reference external" href="https://getnikola.com/extending.html#shortcodes">Extending Nikola</a></p>
- <section id="using-a-shortcode">
- <h2><a class="toc-backref" href="#toc-entry-47" role="doc-backlink">Using a shortcode</a></h2>
- <p>In your content files, a shortcode can be called by using this form:</p>
- <pre class="code text"><a name="rest_code_6b7397d9da374a2d89ab31d8b45b330f-1"></a>{{% name parameters %}}
- </pre><p>Shortcode parameters are space delimited. Parameters with spaces can be quoted (or backslash escaped).</p>
- <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>
- <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>
- <p>Example of a paired shortcode (note that we don't have a highlight shortcode yet ;-):</p>
- <pre class="code text"><a name="rest_code_1e131e5fc6034757a15f5771dcf2b942-1"></a>{{% highlight python %}} A bunch of code here {{% /highlight %}}
- </pre><aside class="admonition admonition-shortcodes-and-restructuredtext">
- <p class="admonition-title">Shortcodes and reStructuredText</p>
- <p>In reStructuredText shortcodes may fail because docutils turns URL into links and everything breaks.
- For some shortcodes there are alternative docutils directives (example, you can use the media
- <strong>directive</strong> instead of the media shortcode.</p>
- <p>Also, you can use the shortcode <strong>role</strong>:</p>
- <pre class="code text"><a name="rest_code_0cacd5f7c1074a69b8a05093efbf003a-1"></a>:sc:`{{% shortcode here %}}`
- </pre><p>That role passes text unaltered, so shortcodes behave correctly.</p>
- </aside>
- </section>
- <section id="built-in-shortcodes">
- <h2><a class="toc-backref" href="#toc-entry-48" role="doc-backlink">Built-in shortcodes</a></h2>
- <aside class="admonition warning">
- <p class="admonition-title">Warning</p>
- <p>Some of the shortcodes are implemented as bindings to reST directives. In
- order to use them, you need at least one entry for <code class="docutils literal">*.rst</code> in
- POSTS/PAGES.</p>
- </aside>
- <dl>
- <dt>chart</dt>
- <dd><p>Create charts via PyGal. This is similar to the <a class="reference external" href="#chart">chart directive</a> except the syntax is adapted to
- shortcodes. This is an example:</p>
- <pre class="code text"><a name="rest_code_9d84fdc1b4ed46b492a2126e3a2c60fc-1"></a>{{% chart Bar title='Browser usage evolution (in %)'
- x_labels='["2002","2003","2004","2005","2006","2007"]' %}}
- 'Firefox', [None, None, 0, 16.6, 25, 31]
- 'Chrome', [None, None, None, None, None, None]
- 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
- 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
- {{% /chart %}}
- </pre><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.
- Example:</p>
- <pre class="code json"><a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-1"></a><span class="p">{</span>
- <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>
- <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-3"></a> <span class="nt">"data"</span><span class="p">:</span> <span class="p">{</span>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-8"></a> <span class="p">}</span>
- <a name="rest_code_ff04f4c00c014e4b944ab66d85f8b3f1-9"></a><span class="p">}</span>
- </pre><p>Which can be used like this:</p>
- <pre class="code text"><a name="rest_code_3e93e8d1415445c19b810e7762374be9-1"></a>{{% chart Bar title='Browser usage evolution (in %)' data_file="posts/browsers.json" %}}
- {{% /chart %}}
-
- </pre><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>
- </dd>
- <dt>doc</dt>
- <dd><p>Will link to a document in the page, see <a class="reference external" href="#doc">Doc role for details</a>. Example:</p>
- <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.
- </pre></dd>
- <dt>emoji</dt>
- <dd><p>Insert an emoji. For example:</p>
- <pre class="code text"><a name="rest_code_e4464a529059439cbf1348acd5c66852-1"></a>{{% emoji crying_face %}}
- </pre><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>
- </dd>
- <dt>gist</dt>
- <dd><p>Show GitHub gists. If you know the gist's ID, this will show it in your site:</p>
- <pre class="code text"><a name="rest_code_ee980f0114414247915df0035769e2e6-1"></a>{{% gist 2395294 %}}
- </pre></dd>
- <dt>listing</dt>
- <dd><p>Used to show a code listing. Example:</p>
- <pre class="code text"><a name="rest_code_2969e45f45a44461bd525578ddd28a35-1"></a>{{% listing hello.py python linenumbers=True %}}
- </pre><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>
- </dd>
- <dt>media</dt>
- <dd><p>Display media embedded from a URL, for example, this will embed a youtube video:</p>
- <pre class="code text"><a name="rest_code_5b57f4c40c5a446da8740b141360f2ca-1"></a>{{% media url=https://www.youtube.com/watch?v=Nck6BZga7TQ %}}
- </pre><p>Note that the shortcode won’t work if your compiler turns URLs into clickable links.</p>
- </dd>
- <dt>post-list</dt>
- <dd><p>Will show a list of posts, see the <a class="reference external" href="#post-list">Post List directive for details</a>.</p>
- </dd>
- <dt>raw</dt>
- <dd><p>Passes the content along, mostly used so I can write this damn section and you can see the shortcodes instead
- of them being munged into shortcode <strong>output</strong>. I can't show an example because Inception.</p>
- </dd>
- <dt>thumbnail</dt>
- <dd><p>Display image thumbnails, with optional captions. Examples:</p>
- <pre class="code text"><a name="rest_code_1361b6c7517446d598a599277dcd9727-1"></a>{{% thumbnail "/images/foo.png" %}}{{% /thumbnail %}}
- <a name="rest_code_1361b6c7517446d598a599277dcd9727-2"></a>{{% thumbnail "/images/foo.png" alt="Foo Image" align="center" %}}{{% /thumbnail %}}
- <a name="rest_code_1361b6c7517446d598a599277dcd9727-3"></a>{{% thumbnail "/images/foo.png" imgclass="image-grayscale" figclass="figure-shadow" %}}<p>Image caption</p>{{% /thumbnail %}}
- <a name="rest_code_1361b6c7517446d598a599277dcd9727-4"></a>{{% thumbnail "/images/foo.png" alt="Foo Image" title="Insert title-text joke here" align="right" %}}<p class="caption">Foo Image (right-aligned) caption</p>{{% /thumbnail %}}
- </pre><p>The following keyword arguments are supported:</p>
- <ul class="simple">
- <li><p>alt (alt text for image)</p></li>
- <li><p>align (image alignment, left/center/right)</p></li>
- <li><p>linktitle (title text for the link, shown by e.g. baguetteBox)</p></li>
- <li><p>title (title text for image)</p></li>
- <li><p>imgclass (class for image)</p></li>
- <li><p>figclass (class for figure, used only if you provide a caption)</p></li>
- </ul>
- <p>Looks similar to the reST thumbnail directive. Caption should be a HTML fragment.</p>
- </dd>
- </dl>
- </section>
- <section id="community-shortcodes">
- <h2><a class="toc-backref" href="#toc-entry-49" role="doc-backlink">Community shortcodes</a></h2>
- <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>
- </section>
- <section id="template-based-shortcodes">
- <h2><a class="toc-backref" href="#toc-entry-50" role="doc-backlink">Template-based shortcodes</a></h2>
- <p>If you put a template in <code class="docutils literal">shortcodes/</code> called <code class="docutils literal">mycode.tmpl</code> then Nikola
- will create a shortcode called <code class="docutils literal">mycode</code> you can use. Any options you pass to
- the shortcode will be available as variables for that template. Non-keyword
- options will be passed in a tuple variable named <code class="docutils literal">_args</code>.</p>
- <p>The post in which the shortcode is being used is available as the <code class="docutils literal">post</code>
- variable, so you can access the title as <code class="docutils literal">post.title</code>, and data loaded
- via the <code class="docutils literal">data</code> field in the metadata using <code class="docutils literal">post.data(key)</code>.</p>
- <p>If you use the shortcode as paired, then the contents between the paired tags
- will be available in the <code class="docutils literal">data</code> variable. If you want to access the Nikola
- object, it will be available as <code class="docutils literal">site</code>. Use with care :-)</p>
- <aside class="admonition note">
- <p class="admonition-title">Note</p>
- <p>Template-based shortcodes use the same template engine as your site’s theme.</p>
- </aside>
- <p>See <a class="reference external" href="/pages/extending.html">Extending Nikola</a> for detailed information.</p>
- <p>For example, if your <code class="docutils literal">shortcodes/foo.tmpl</code> contains this:</p>
- <pre class="code text"><a name="rest_code_6035c8ab23004e31be536b9f949cdba5-1"></a>This uses the bar variable: ${bar}
- </pre><p>And your post contains this:</p>
- <pre class="code text"><a name="rest_code_0bb098b26f0347419ebbf54484a32c1a-1"></a>{{% foo bar=bla %}}
- </pre><p>Then the output file will contain:</p>
- <pre class="code text"><a name="rest_code_0adb60b492ec499d93accd1efb9fcf9d-1"></a>This uses the bar variable: bla
- </pre><p>Finally, you can use a template shortcode without a file, by inserting the
- template in the shortcode itself:</p>
- <pre class="code html+mako"><a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-1"></a>{{% template %}}
- <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-2"></a><span class="p"><</span><span class="nt">ul</span><span class="p">></span>
- <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>
- <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-4"></a><span class="p"><</span><span class="nt">li</span><span class="p">></span><span class="cp">${</span><span class="n">foo</span><span class="cp">}</span><span class="p"></</span><span class="nt">li</span><span class="p">></span>
- <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-5"></a><span class="cp">%</span><span class="k"> endfor</span>
- <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-6"></a><span class="p"></</span><span class="nt">ul</span><span class="p">></span>
- <a name="rest_code_3c12261a69e547b0aac11a3a4a15a504-7"></a>{{% /template %}}
- </pre><p>In that case, the template engine used will be your theme's and the arguments you pass,
- as well as the global context from your <code class="docutils literal">conf.py</code>, are available to the template you
- are creating.</p>
- <p>You can use anything defined in your configuration's <code class="docutils literal">GLOBAL_CONTEXT</code> as
- variables in your shortcode template, with a caveat: Because of an unfortunate
- implementation detail (a name conflict), <code class="docutils literal">data</code> is called <code class="docutils literal">global_data</code>
- when used in a shortcode.</p>
- <p>If you have some template code that you want to appear in both a template and
- shortcode, you can put the shared code in a separate template and import it in both
- places. Shortcodes can import any template inside <code class="docutils literal">templates/</code> and themes,
- and call any macros defined in those.</p>
- <p>For example, if you define a macro <code class="docutils literal">foo(x, y)</code> in
- <code class="docutils literal">templates/shared_sc.tmpl</code>, you can include <code class="docutils literal">shared_foo.tmpl</code> in
- <code class="docutils literal">templates/special_post.tmpl</code> and <code class="docutils literal">shortcodes/foo.tmpl</code> and then call the
- <code class="docutils literal">${shared_foo.foo(x, y)}</code> macro.</p>
- </section>
- </section>
- <section id="the-global-context-and-data-files">
- <h1><a class="toc-backref" href="#toc-entry-51" role="doc-backlink">The Global Context and Data files</a></h1>
- <p>There is a <code class="docutils literal">GLOBAL_CONTEXT</code> field in your <code class="docutils literal">conf.py</code> where you can
- put things you want to make available to your templates.</p>
- <p>It will also contain things you put in a <code class="docutils literal">data/</code> directory within your
- site. You can use JSON, YAML or TOML files (with the appropriate file
- extensions: json/js, yaml/yml, toml/tml) that decode to Python dictionaries.
- For example, if you create <code class="docutils literal">data/foo.json</code> containing this:</p>
- <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>
- </pre><p>Then your templates can use things like <code class="docutils literal"><span class="pre">${data['foo']['bar']}</span></code> and
- it will be replaced by "baz".</p>
- <p>Individual posts can also have a data file. Those are specified using the
- <code class="docutils literal">data</code> meta field (path relative to <code class="docutils literal">conf.py</code>, can be different in
- different post languages). Those are accessible as eg.
- <code class="docutils literal"><span class="pre">${post.data['bar']}</span></code> in templates. <a class="reference internal" href="#template-based-shortcodes">Template-based shortcodes</a> are a
- good idea in this case.</p>
- <p>Data files can be useful for eg. auto-generated sites, where users provide
- JSON/YAML/TOML files and Nikola generates a large page with data from all data
- files. (This is especially useful with some automatic rebuild feature, like
- those documented in <a class="reference internal" href="#deployment">Deployment</a>)</p>
- <p>Data files are also available as <code class="docutils literal">global_data</code>, to avoid name conflicts in
- shortcodes. (<code class="docutils literal">global_data</code> works everywhere.)</p>
- </section>
- <section id="redirections">
- <h1><a class="toc-backref" href="#toc-entry-52" role="doc-backlink">Redirections</a></h1>
- <p>If you need a page to be available in more than one place, you can define redirections
- in your <code class="docutils literal">conf.py</code>:</p>
- <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>
- <a name="rest_code_f95788d007ac4386a97f12dc20469dac-2"></a><span class="c1">#</span>
- <a name="rest_code_f95788d007ac4386a97f12dc20469dac-3"></a><span class="c1"># A HTML file will be created in output/foo/from.html that redirects</span>
- <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>
- <a name="rest_code_f95788d007ac4386a97f12dc20469dac-5"></a><span class="c1"># relative URL.</span>
- <a name="rest_code_f95788d007ac4386a97f12dc20469dac-6"></a><span class="c1">#</span>
- <a name="rest_code_f95788d007ac4386a97f12dc20469dac-7"></a><span class="c1"># If you don't need any of these, just set to []</span>
- <a name="rest_code_f95788d007ac4386a97f12dc20469dac-8"></a>
- <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>
- </pre><p>It's better if you can do these using your web server's configuration, but if
- you can't, this will work.</p>
- </section>
- <section id="configuration">
- <h1><a class="toc-backref" href="#toc-entry-53" role="doc-backlink">Configuration</a></h1>
- <p>The configuration file can be used to customize a lot of what Nikola does. Its
- syntax is python, but if you don't know the language, it still should not be
- terribly hard to grasp.</p>
- <p>By default, the <code class="docutils literal">conf.py</code> file in the root of the Nikola website will be used.
- 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>
- <p>The default <code class="docutils literal">conf.py</code> you get with Nikola should be fairly complete, and is quite
- commented.</p>
- <p>You surely want to edit these options:</p>
- <pre class="code python"><a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-1"></a><span class="c1"># Data about this site</span>
- <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>
- <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>
- <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-4"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"https://getnikola.com/"</span>
- <a name="rest_code_4da99e4aa3f5496d82635ede892e09e3-5"></a><span class="n">BLOG_EMAIL</span> <span class="o">=</span> <span class="s2">"joe@demo.site"</span>
- <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>
- </pre><p>Some options are marked with a (translatable) comment above or right next to
- them. For those options, two types of values can be provided:</p>
- <ul class="simple">
- <li><p>a string, which will be used for all languages</p></li>
- <li><p>a dict of language-value pairs, to have different values in each language</p></li>
- </ul>
- <aside class="admonition note">
- <p class="admonition-title">Note</p>
- <p>As of version 8.0.3 it is possible to create configuration files which inherit values from other Python files.
- This might be useful if you're working with similar environments.</p>
- <dl>
- <dt>Example:</dt>
- <dd><dl>
- <dt>conf.py:</dt>
- <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>
- <a name="rest_code_87474c99ec32407e8f46318d9078dc38-2"></a><span class="n">BLOG_TITLE</span> <span class="o">=</span> <span class="s2">"Demo Site"</span>
- <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>
- <a name="rest_code_87474c99ec32407e8f46318d9078dc38-4"></a><span class="n">BLOG_EMAIL</span> <span class="o">=</span> <span class="s2">"joe@demo.site"</span>
- <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>
- </pre></dd>
- <dt>debug.conf.py:</dt>
- <dd><pre class="code python"><a name="rest_code_cfcf7893d7434f33aff1a30ef65edc10-1"></a><span class="kn">import</span> <span class="nn">conf</span>
- <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>
- <a name="rest_code_cfcf7893d7434f33aff1a30ef65edc10-3"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"http://localhost:8000/"</span>
- </pre><p>or</p>
- <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>
- <a name="rest_code_7263480f318a4ad2808bb1440153a1f8-2"></a><span class="n">SITE_URL</span> <span class="o">=</span> <span class="s2">"http://localhost:8000/"</span>
- </pre></dd>
- </dl>
- </dd>
- </dl>
- </aside>
- </section>
- <section id="customizing-your-site">
- <h1><a class="toc-backref" href="#toc-entry-54" role="doc-backlink">Customizing Your Site</a></h1>
- <p>There are lots of things you can do to personalize your website, but let's see
- the easy ones!</p>
- <dl>
- <dt>CSS tweaking</dt>
- <dd><p>Using the default configuration, you can create a <code class="docutils literal">assets/css/custom.css</code>
- file under <code class="docutils literal">files/</code> or in your theme and then it will be loaded from the
- <code class="docutils literal"><head></code> blocks of your site pages. Create it and put your CSS code there,
- for minimal disruption of the provided CSS files.</p>
- <p>If you feel tempted to touch other files in assets, you probably will be better off
- with a <a class="reference external" href="/pages/theming.html">custom theme</a>.</p>
- <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
- contains LESS or Sass code that you want to override, you will need to install
- the <a class="reference external" href="https://plugins.getnikola.com/#less">LESS plugin</a> or
- <a class="reference external" href="https://plugins.getnikola.com/#sass">SASS plugin</a> create a <code class="docutils literal">less</code> or
- <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
- there and a targets file containing the list of files you want compiled.</p>
- </dd>
- </dl>
- <dl>
- <dt>Template tweaking and creating themes</dt>
- <dd><p>If you really want to change the pages radically, you will want to do a
- <a class="reference external" href="/pages/theming.html">custom theme</a>.</p>
- </dd>
- <dt>Navigation Links</dt>
- <dd><p>The <code class="docutils literal">NAVIGATION_LINKS</code> option lets you define what links go in a sidebar or menu
- (depending on your theme) so you can link to important pages, or to other sites.</p>
- <p>The format is a language-indexed dictionary, where each element is a tuple of
- tuples which are one of:</p>
- <ol class="arabic simple">
- <li><p>A (url, text) tuple, describing a link</p></li>
- <li><p>A (((url, text), (url, text), (url, text)), title) tuple, describing a submenu / sublist.</p></li>
- </ol>
- <p>Example:</p>
- <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>
- <a name="rest_code_2ac806e68e064632b07a82714691b167-2"></a> <span class="n">DEFAULT_LANG</span><span class="p">:</span> <span class="p">(</span>
- <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>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_2ac806e68e064632b07a82714691b167-8"></a> <span class="p">),</span>
- <a name="rest_code_2ac806e68e064632b07a82714691b167-9"></a><span class="p">}</span>
- </pre><aside class="admonition note">
- <p class="admonition-title">Note</p>
- <ol class="arabic simple">
- <li><p>Support for submenus is theme-dependent. Only one level of
- submenus is supported.</p></li>
- <li><p>Some themes, including the default Bootstrap theme, may
- present issues if the menu is too large. (in Bootstrap, the navbar
- can grow too large and cover contents.)</p></li>
- <li><p>If you link to directories, make sure to follow <code class="docutils literal">STRIP_INDEXES</code>. If
- it’s set to <code class="docutils literal">True</code>, end your links with a <code class="docutils literal">/</code>, otherwise end them
- with <code class="docutils literal">/index.html</code> — or else they won’t be highlighted when active.</p></li>
- </ol>
- </aside>
- <p>There’s also <code class="docutils literal">NAVIGATION_ALT_LINKS</code>. Themes may display this somewhere
- else, or not at all. Bootstrap puts it on the right side of the header.</p>
- <p>The <code class="docutils literal">SEARCH_FORM</code> option contains the HTML code for a search form based on
- duckduckgo.com which should always work, but feel free to change it to
- something else.</p>
- </dd>
- <dt>Footer</dt>
- <dd><p><code class="docutils literal">CONTENT_FOOTER</code> is displayed, small at the bottom of all pages, I use it for
- the copyright notice. The default shows a text formed using <code class="docutils literal">BLOG_AUTHOR</code>,
- <code class="docutils literal">BLOG_EMAIL</code>, the date and <code class="docutils literal">LICENSE</code>. Note you need to use
- <code class="docutils literal">CONTENT_FOOTER_FORMATS</code> instead of regular str.format or %-formatting,
- for compatibility with the translatable settings feature.</p>
- </dd>
- <dt>BODY_END</dt>
- <dd><p>This option lets you define a HTML snippet that will be added at the bottom of body.
- The main usage is a Google analytics snippet or something similar, but you can really
- put anything there. Good place for JavaScript.</p>
- </dd>
- <dt>SOCIAL_BUTTONS_CODE</dt>
- <dd><p>The <code class="docutils literal">SOCIAL_BUTTONS_CODE</code> option lets you define a HTML snippet that will be added
- at the bottom of body. It defaults to a snippet for AddThis, but you can
- really put anything there. See <cite>social_buttons.html</cite> for more details.</p>
- </dd>
- </dl>
- </section>
- <section id="fancy-dates">
- <h1><a class="toc-backref" href="#toc-entry-55" role="doc-backlink">Fancy Dates</a></h1>
- <p>Nikola can use various styles for presenting dates.</p>
- <dl class="simple">
- <dt>DATE_FORMAT</dt>
- <dd><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>
- </dd>
- <dt>LUXON_DATE_FORMAT</dt>
- <dd><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>
- </dd>
- <dt>MOMENTJS_DATE_FORMAT (formerly JS_DATE_FORMAT)</dt>
- <dd><p>The date format to use if fancy dates are on, and the theme is using Moment.js.</p>
- </dd>
- <dt>DATE_FANCINESS = 0</dt>
- <dd><p>Fancy dates are off, and DATE_FORMAT is used.</p>
- </dd>
- <dt>DATE_FANCINESS = 1</dt>
- <dd><p>Dates are recalculated in user’s timezone. Requires JavaScript.</p>
- </dd>
- <dt>DATE_FANCINESS = 2</dt>
- <dd><p>Dates are recalculated as relative time (eg. 2 days ago). Requires JavaScript.</p>
- </dd>
- </dl>
- <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>
- <p>For Mako:</p>
- <pre class="code html"><a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-1"></a>% if date_fanciness != 0:
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-2"></a>%if date_fanciness == 2:
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-3"></a> <span class="c"><!-- Polyfill for relative dates in Safari -- best handled with a CDN --></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-4"></a> <span class="p"><</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">></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-5"></a>%endif
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-6"></a><span class="c"><!-- required scripts -- best handled with bundles --></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-7"></a><span class="p"><</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">></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-8"></a><span class="p"><</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">></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-9"></a>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-10"></a><span class="c"><!-- fancy dates code --></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-11"></a><span class="p"><</span><span class="nt">script</span><span class="p">></span>
- <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>
- <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>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-14"></a><span class="p"></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-15"></a><span class="c"><!-- end fancy dates code --></span>
- <a name="rest_code_b81e3d14c71445e0a6d3590aeaba7932-16"></a>%endif
- </pre><p>For Jinja2:</p>
- <pre class="code html"><a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-1"></a>{% if date_fanciness != 0 %}
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-2"></a>{% if date_fanciness == 2 %}
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-3"></a> <span class="c"><!-- Polyfill for relative dates in Safari -- best handled with a CDN --></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-4"></a> <span class="p"><</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">></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-5"></a>{% endif %}
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-6"></a><span class="c"><!-- required scripts -- best handled with bundles --></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-7"></a><span class="p"><</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">></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-8"></a><span class="p"><</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">></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-9"></a>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-10"></a><span class="c"><!-- fancy dates code --></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-11"></a><span class="p"><</span><span class="nt">script</span><span class="p">></span>
- <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>
- <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>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-14"></a><span class="p"></</span><span class="nt">script</span><span class="p">></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-15"></a><span class="c"><!-- end fancy dates code --></span>
- <a name="rest_code_5a2dc5b84dd546e4bc7b4677b9260978-16"></a>{% endif %}
- </pre></section>
- <section id="adding-files">
- <h1><a class="toc-backref" href="#toc-entry-56" role="doc-backlink">Adding Files</a></h1>
- <p>Any files you want to be in <code class="docutils literal">output/</code> but are not generated by Nikola (for
- example, <code class="docutils literal">favicon.ico</code>) should be placed in <code class="docutils literal">files/</code>. Remember that you
- can't have files that collide with files Nikola generates (it will give an
- error).</p>
- <aside class="admonition admonition-important">
- <p class="admonition-title">Important</p>
- <p>Don't put any files manually in <code class="docutils literal">output/</code>. Ever. Really.
- 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>
- </aside>
- <p>If you want to copy more than one folder of static files into <code class="docutils literal">output</code> you can
- change the FILES_FOLDERS option:</p>
- <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>
- <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-2"></a><span class="c1"># The format is a dictionary of "source" "relative destination".</span>
- <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-3"></a><span class="c1"># Default is:</span>
- <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-4"></a><span class="c1"># FILES_FOLDERS = {'files': '' }</span>
- <a name="rest_code_09e5165e8fff4f77ae2e570ef43b950c-5"></a><span class="c1"># Which means copy 'files' into 'output'</span>
- </pre></section>
- <section id="custom-themes">
- <h1><a class="toc-backref" href="#toc-entry-57" role="doc-backlink">Custom Themes</a></h1>
- <p>If you prefer to have a custom appearance for your site, and modifying CSS
- files and settings (see <a class="reference internal" href="#customizing-your-site">Customizing Your Site</a> for details) is not enough,
- you can create your own theme. See the <a class="reference external" href="/pages/theming.html">Theming Nikola</a> and
- <a class="reference external" href="/pages/creating-a-theme.html">Creating a Theme</a> for more details. You can put them in a <code class="docutils literal">themes/</code>
- folder and set <code class="docutils literal">THEME</code> to the directory name. You can also put them in
- directories listed in the <code class="docutils literal">EXTRA_THEMES_DIRS</code> configuration variable.</p>
- </section>
- <section id="getting-extra-themes">
- <h1><a class="toc-backref" href="#toc-entry-58" role="doc-backlink">Getting Extra Themes</a></h1>
- <p>There are a few themes for Nikola. They are available at
- the <a class="reference external" href="https://themes.getnikola.com/">Themes Index</a>.
- Nikola has a built-in theme download/install mechanism to install those themes
- — the <code class="docutils literal">theme</code> command:</p>
- <pre class="code console"><a name="rest_code_f2f92738a0074fba924eafed3daacedb-1"></a><span class="gp">$</span> nikola theme -l
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-2"></a><span class="go">Themes:</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-3"></a><span class="go">-------</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-4"></a><span class="go">blogtxt</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-5"></a><span class="go">bootstrap3-gradients</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-6"></a><span class="go">⋮</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-7"></a><span class="go">⋮</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-8"></a>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-9"></a><span class="gp">$</span> nikola theme -i blogtxt
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-10"></a><span class="go">[2013-10-12T16:46:13Z] NOTICE: theme: Downloading:</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-11"></a><span class="go">https://themes.getnikola.com/v6/blogtxt.zip</span>
- <a name="rest_code_f2f92738a0074fba924eafed3daacedb-12"></a><span class="go">[2013-10-12T16:46:15Z] NOTICE: theme: Extracting: blogtxt into themes</span>
- </pre><p>And there you are, you now have themes/blogtxt installed. It's very
- rudimentary, but it should work in most cases.</p>
- <p>If you create a nice theme, please share it! You can do it as a pull
- request in the <a class="reference external" href="https://github.com/getnikola/nikola-themes">GitHub repository</a>.</p>
- <p>One other option is to tweak an existing theme using a different color scheme,
- typography and CSS in general. Nikola provides a <code class="docutils literal">subtheme</code> command
- to create a custom theme by downloading free CSS files from <a class="reference external" href="https://bootswatch.com">https://bootswatch.com</a>
- and <a class="reference external" href="https://hackerthemes.com">https://hackerthemes.com</a></p>
- <pre class="code console"><a name="rest_code_f85a98af5f764ca581778646283fe1d4-1"></a><span class="gp">$</span> nikola subtheme -n custom_theme -s flatly -p bootstrap4
- <a name="rest_code_f85a98af5f764ca581778646283fe1d4-2"></a><span class="go">[2013-10-12T16:46:58Z] NOTICE: subtheme: Creating 'custom_theme' theme</span>
- <a name="rest_code_f85a98af5f764ca581778646283fe1d4-3"></a><span class="go">from 'flatly' and 'bootstrap4'</span>
- <a name="rest_code_f85a98af5f764ca581778646283fe1d4-4"></a><span class="go">[2013-10-12T16:46:58Z] NOTICE: subtheme: Downloading:</span>
- <a name="rest_code_f85a98af5f764ca581778646283fe1d4-5"></a><span class="go">http://bootswatch.com/flatly/bootstrap.min.css</span>
- <a name="rest_code_f85a98af5f764ca581778646283fe1d4-6"></a><span class="go">[2013-10-12T16:46:58Z] NOTICE: subtheme: Downloading:</span>
- <a name="rest_code_f85a98af5f764ca581778646283fe1d4-7"></a><span class="go">http://bootswatch.com/flatly/bootstrap.css</span>
- <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>
- </pre><p>Play with it, there's cool stuff there. This feature was suggested by
- <a class="reference external" href="http://elgalpondebanquito.com.ar">clodo</a>.</p>
- </section>
- <section id="deployment">
- <h1><a class="toc-backref" href="#toc-entry-59" role="doc-backlink">Deployment</a></h1>
- <p>If you can specify your deployment procedure as a series of commands, you can
- put them in the <code class="docutils literal">DEPLOY_COMMANDS</code> option, and run them with <code class="docutils literal">nikola deploy</code>.</p>
- <p>You can have multiple deployment presets. If you run <code class="docutils literal">nikola deploy</code>, the
- <code class="docutils literal">default</code> preset is executed. You can also specify the names of presets
- you want to run (eg. <code class="docutils literal">nikola deploy default</code>, multiple presets are allowed).</p>
- <p>One caveat is that if any command has a % in it, you should double them.</p>
- <p>Here is an example, from my own site's deployment script:</p>
- <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>
- <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>
- <a name="rest_code_59a2999f62f44b56ac9e57ae60039238-3"></a> <span class="s1">'rdiff-backup output ~/blog-backup'</span><span class="p">,</span>
- <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>
- <a name="rest_code_59a2999f62f44b56ac9e57ae60039238-5"></a><span class="p">]}</span>
- </pre><p>Other interesting ideas are using
- <a class="reference external" href="https://toroid.org/git-website-howto">git as a deployment mechanism</a> (or any other VCS
- for that matter), using <a class="reference external" href="https://lftp.yar.ru/">lftp mirror</a> or unison, or Dropbox.
- Any way you can think of to copy files from one place to another is good enough.</p>
- <section id="deploying-to-github">
- <h2><a class="toc-backref" href="#toc-entry-60" role="doc-backlink">Deploying to GitHub</a></h2>
- <p>Nikola provides a separate command <code class="docutils literal">github_deploy</code> to deploy your site to
- GitHub Pages. The command builds the site, commits the output to a gh-pages
- 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>
- <p>In order to use this feature, you need to configure a few things first. Make
- sure you have <code class="docutils literal">nikola</code> and <code class="docutils literal">git</code> installed on your PATH.</p>
- <ol class="arabic">
- <li><p>Initialize a Nikola site, if you haven’t already.</p></li>
- <li><p>Initialize a git repository in your Nikola source directory by running:</p>
- <pre class="code text"><a name="rest_code_a15b8909505542b9a3d2dab06521e85e-1"></a>git init .
- <a name="rest_code_a15b8909505542b9a3d2dab06521e85e-2"></a>git remote add origin git@github.com:user/repository.git
- </pre></li>
- <li><p>Setup branches and remotes in <code class="docutils literal">conf.py</code>:</p>
- <ul class="simple">
- <li><p><code class="docutils literal">GITHUB_DEPLOY_BRANCH</code> is the branch where Nikola-generated HTML files
- will be deployed. It should be <code class="docutils literal"><span class="pre">gh-pages</span></code> for project pages and
- <code class="docutils literal">master</code> for user pages (user.github.io).</p></li>
- <li><p><code class="docutils literal">GITHUB_SOURCE_BRANCH</code> is the branch where your Nikola site source will be
- deployed. We recommend and default to <code class="docutils literal">src</code>.</p></li>
- <li><p><code class="docutils literal">GITHUB_REMOTE_NAME</code> is the remote to which changes are pushed.</p></li>
- <li><p><code class="docutils literal">GITHUB_COMMIT_SOURCE</code> controls whether or not the source branch is
- automatically committed to and pushed. We recommend setting it to
- <code class="docutils literal">True</code>, unless you are automating builds with CI (eg. GitHub Actions/GitLab CI).</p></li>
- </ul>
- </li>
- <li><p>Create a <code class="docutils literal">.gitignore</code> file. We recommend adding at least the following entries:</p>
- <pre class="code text"><a name="rest_code_90245400f63d48fb926bf20a090dd223-1"></a>cache
- <a name="rest_code_90245400f63d48fb926bf20a090dd223-2"></a>.doit.db
- <a name="rest_code_90245400f63d48fb926bf20a090dd223-3"></a>__pycache__
- <a name="rest_code_90245400f63d48fb926bf20a090dd223-4"></a>output
- </pre></li>
- <li><p>If you set <code class="docutils literal">GITHUB_COMMIT_SOURCE</code> to False, you must switch to your source
- branch and commit to it. Otherwise, this is done for you.</p></li>
- <li><p>Run <code class="docutils literal">nikola github_deploy</code>. This will build the site, commit the output
- folder to your deploy branch, and push to GitHub. Your website should be up
- and running within a few minutes.</p></li>
- </ol>
- <p>If you want to use a custom domain, create your <code class="docutils literal">CNAME</code> file in
- <code class="docutils literal">files/CNAME</code> on the source branch. Nikola will copy it to the
- output directory. To add a custom commit message, use the <code class="docutils literal"><span class="pre">-m</span></code> option,
- followed by your message.</p>
- </section>
- <section id="automated-rebuilds-github-actions-gitlab">
- <h2><a class="toc-backref" href="#toc-entry-61" role="doc-backlink">Automated rebuilds (GitHub Actions, GitLab)</a></h2>
- <p>If you want automated rebuilds and GitHub Pages deployment, allowing you to
- blog from anywhere in the world, you have multiple options:</p>
- <ul class="simple">
- <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>
- <li><p><a class="reference external" href="https://gitlab.com/pages/nikola">Example Nikola site for GitLab Pages</a></p></li>
- </ul>
- </section>
- </section>
- <section id="comments">
- <h1><a class="toc-backref" href="#toc-entry-62" role="doc-backlink">Comments</a></h1>
- <p>While Nikola creates static sites, there is a minimum level of user interaction you
- are probably expecting: comments.</p>
- <p>Nikola supports several third party comment systems:</p>
- <ul class="simple">
- <li><p><a class="reference external" href="https://disqus.com">DISQUS</a></p></li>
- <li><p><a class="reference external" href="https://www.intensedebate.com/">IntenseDebate</a></p></li>
- <li><p><a class="reference external" href="https://muut.com/">Muut (Formerly moot)</a></p></li>
- <li><p><a class="reference external" href="https://facebook.com/">Facebook</a></p></li>
- <li><p><a class="reference external" href="https://posativ.org/isso/">Isso</a></p></li>
- <li><p><a class="reference external" href="https://github.com/adtac/commento">Commento</a></p></li>
- <li><p><a class="reference external" href="https://utteranc.es/">Utterances</a></p></li>
- </ul>
- <p>By default it will use DISQUS, but you can change by setting <code class="docutils literal">COMMENT_SYSTEM</code>
- to one of "disqus", "intensedebate", "livefyre", "moot", "facebook", "isso", "commento" or "utterances".
- It is also possible to use a comment system added by a plugin, see the
- <a class="reference external" href="https://plugins.getnikola.com/#cactuscomments">Cactus Comments plugin</a> for an example.</p>
- <aside class="sidebar">
- <p class="sidebar-title"><code class="docutils literal">COMMENT_SYSTEM_ID</code></p>
- <p>The value of <code class="docutils literal">COMMENT_SYSTEM_ID</code> depends on what comment system you
- are using and you can see it in the system's admin interface.</p>
- <ul class="simple">
- <li><p>For DISQUS, it's called the <strong>shortname</strong></p></li>
- <li><p>For IntenseDebate, it's the <strong>IntenseDebate site acct</strong></p></li>
- <li><p>For Muut, it's your <strong>username</strong></p></li>
- <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!)
- and get an <strong>App ID</strong></p></li>
- <li><p>For Isso, it's the URL of your Isso instance (must be world-accessible, encoded with
- Punycode (if using Internationalized Domain Names) and <strong>have a trailing slash</strong>,
- default <code class="docutils literal"><span class="pre">http://localhost:8080/</span></code>). You can add custom config options via
- <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>
- <li><p>For Commento, it's the URL of the commento instance as required by the <code class="docutils literal">serverUrl</code>
- parameter in commento's documentation.</p></li>
- <li><p>For Utterances, it's the <strong>repo name</strong> (<code class="docutils literal">"org/user"</code>) on GitHub whose
- issue tracker is used for comments. Additional Utterances configuration
- values can be stored in the <code class="docutils literal">GLOBAL_CONTEXT</code>, e.g.,
- <code class="docutils literal"><span class="pre">GLOBAL_CONTEXT['utterances_config']</span> = <span class="pre">{"issue-term":</span> "title",
- "label": "Comments", "theme": <span class="pre">"github-light",</span> "crossorigin": "anonymous")</code>.</p></li>
- </ul>
- </aside>
- <p>To use comments in a visible site, you should register with the service and
- then set the <code class="docutils literal">COMMENT_SYSTEM_ID</code> option.</p>
- <p>I recommend 3rd party comments, and specially DISQUS because:</p>
- <ol class="arabic simple">
- <li><p>It doesn't require any server-side software on your site</p></li>
- <li><p>They offer you a way to export your comments, so you can take
- them with you if you need to.</p></li>
- <li><p>It's free.</p></li>
- <li><p>It's damn nice.</p></li>
- </ol>
- <p>You can disable comments for a post by adding a "nocomments" metadata field to it:</p>
- <pre class="code restructuredtext"><a name="rest_code_525b990adf414fd08e4d6266a1116147-1"></a><span class="cp">.. nocomments: True</span>
- </pre><aside class="admonition admonition-disqus-support">
- <p class="admonition-title">DISQUS Support</p>
- <p>In some cases, when you run the test site, you won't see the comments.
- That can be fixed by adding the disqus_developer flag to the templates
- but it's probably more trouble than it's worth.</p>
- </aside>
- <aside class="admonition admonition-moot-support">
- <p class="admonition-title">Moot Support</p>
- <p>Moot doesn't support comment counts on index pages, and it requires adding
- this to your <code class="docutils literal">conf.py</code>:</p>
- <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>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-2"></a><span class="s2"><script src="//cdn.moot.it/1/moot.min.js"></script></span>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-3"></a><span class="s2">"""</span>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-4"></a><span class="n">EXTRA_HEAD_DATA</span> <span class="o">=</span> <span class="s2">"""</span>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-5"></a><span class="s2"><link rel="stylesheet" type="text/css" href="//cdn.moot.it/1/moot.css"></span>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-6"></a><span class="s2"><meta name="viewport" content="width=device-width"></span>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-7"></a><span class="s2"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></span>
- <a name="rest_code_5c61e269dd714e42bd2cb04e330a4be5-8"></a><span class="s2">"""</span>
- </pre></aside>
- <aside class="admonition admonition-facebook-support">
- <p class="admonition-title">Facebook Support</p>
- <p>You need jQuery, but not because Facebook wants it (see Issue
- #639).</p>
- </aside>
- <aside class="admonition admonition-utterances-support">
- <p class="admonition-title">Utterances Support</p>
- <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>,
- except for <code class="docutils literal">repo</code>, which should be set as <code class="docutils literal">COMMENT_SYSTEM_ID</code>. Note
- 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
- other Utterances configuration options are optional.</p>
- </aside>
- </section>
- <section id="images-and-galleries">
- <h1><a class="toc-backref" href="#toc-entry-63" role="doc-backlink">Images and Galleries</a></h1>
- <p>To create an image gallery, all you have to do is add a folder inside <code class="docutils literal">galleries</code>,
- and put images there. Nikola will take care of creating thumbnails, index page, etc.</p>
- <p>If you click on images on a gallery, or on images with links in post, you will
- 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
- <code class="docutils literal">.islink</code> class to your link.</p>
- <p>The gallery pages are generated using the <code class="docutils literal">gallery.tmpl</code> template, and you can
- customize it there (you could switch to another lightbox instead of baguetteBox, change
- its settings, change the layout, etc.).</p>
- <p>Images in galleries may be provided with captions and given a specific
- ordering, by creating a file in the gallery directory called <code class="docutils literal">metadata.yml</code>.
- This YAML file should contain a <code class="docutils literal">name</code> field for each image in the gallery
- for which you wish to provide either a caption or specific ordering. You can also
- create localized versions (<code class="docutils literal">metadata.xx.yml</code>).</p>
- <p>Only one <code class="docutils literal">metadata.yml</code> is needed per gallery. Here is an example, showing names,
- captions and ordering. <code class="docutils literal">caption</code> and <code class="docutils literal">order</code> are given special treatment,
- anything else is available to templates, as keys of <code class="docutils literal">photo_array</code> images.</p>
- <pre class="code yaml"><a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-1"></a><span class="nn">---</span>
- <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>
- <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-3"></a><span class="nn">---</span>
- <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>
- <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>
- <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-6"></a><span class="nn">---</span>
- <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>
- <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>
- <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>
- <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-10"></a><span class="nn">---</span>
- <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>
- <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>
- <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>
- <a name="rest_code_a5ab5add4fc3486eabe3cdd5d1f61ead-14"></a><span class="nn">---</span>
- </pre><p>Images to be used in normal posts can be placed in the <code class="docutils literal">images</code> folder. These
- images will be processed and have thumbnails created just as for galleries, but will
- then be copied directly to the corresponding path in the <code class="docutils literal">output</code> directory, so you
- can reference it from whatever page you like, most easily using the <code class="docutils literal">thumbnail</code>
- reST extension. If you don't want thumbnails, just use the <code class="docutils literal">files</code> folder instead.</p>
- <p>The <code class="docutils literal">conf.py</code> options affecting images and gallery pages are these:</p>
- <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>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-2"></a><span class="c1"># {"source": "relative_destination"}, where galleries are looked for in</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-3"></a><span class="c1"># "source/" and the results will be located in</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-4"></a><span class="c1"># "OUTPUT_PATH/relative_destination/gallery_name"</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-5"></a><span class="c1"># Default is:</span>
- <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>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-7"></a><span class="c1"># More gallery options:</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-8"></a><span class="n">THUMBNAIL_SIZE</span> <span class="o">=</span> <span class="mi">180</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-9"></a><span class="n">MAX_IMAGE_SIZE</span> <span class="o">=</span> <span class="mi">1280</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-10"></a><span class="n">USE_FILENAME_AS_TITLE</span> <span class="o">=</span> <span class="kc">True</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-11"></a><span class="n">EXTRA_IMAGE_EXTENSIONS</span> <span class="o">=</span> <span class="p">[]</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-12"></a>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-13"></a><span class="c1"># Use a thumbnail (defined by ".. previewimage:" in the gallery's index) in</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-14"></a><span class="c1"># list of galleries for each gallery</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-15"></a><span class="n">GALLERIES_USE_THUMBNAIL</span> <span class="o">=</span> <span class="kc">False</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-16"></a>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-17"></a><span class="c1"># Image to use as thumbnail for those galleries that don't have one</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-18"></a><span class="c1"># None: show a grey square</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-19"></a><span class="c1"># '/url/to/file': show the image in that url</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-20"></a><span class="n">GALLERIES_DEFAULT_THUMBNAIL</span> <span class="o">=</span> <span class="kc">None</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-21"></a>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-22"></a><span class="c1"># If set to False, it will sort by filename instead. Defaults to True</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-23"></a><span class="n">GALLERY_SORT_BY_DATE</span> <span class="o">=</span> <span class="kc">True</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-24"></a>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-25"></a><span class="c1"># Folders containing images to be used in normal posts or pages.</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-26"></a><span class="c1"># IMAGE_FOLDERS is a dictionary of the form {"source": "destination"},</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-27"></a><span class="c1"># where "source" is the folder containing the images to be published, and</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-28"></a><span class="c1"># "destination" is the folder under OUTPUT_PATH containing the images copied</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-29"></a><span class="c1"># to the site. Thumbnail images will be created there as well.</span>
- <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>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-31"></a>
- <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>
- <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>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-34"></a><span class="c1"># (the thumbnail has ``.thumbnail`` added before the file extension by default,</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-35"></a><span class="c1"># but a different naming template can be configured with IMAGE_THUMBNAIL_FORMAT).</span>
- <a name="rest_code_8805d8ef5320446780b0942becf47084-36"></a><span class="n">IMAGE_THUMBNAIL_SIZE</span> <span class="o">=</span> <span class="mi">400</span>
- <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>
- </pre><p>If you add a reST file in <code class="docutils literal">galleries/gallery_name/index.txt</code> its contents will be
- converted to HTML and inserted above the images in the gallery page. The
- format is the same as for posts. You can use the <code class="docutils literal">title</code>, <code class="docutils literal">previewimage</code>, and
- <code class="docutils literal">status</code> metadata fields to change how the gallery is shown.</p>
- <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
- gallery will not appear in the index, the RSS feeds, nor in the sitemap.</p>
- <p>If you add some image filenames in <code class="docutils literal">galleries/gallery_name/exclude.meta</code>, they
- will be excluded in the gallery page.</p>
- <p>If <code class="docutils literal">USE_FILENAME_AS_TITLE</code> is True the filename (parsed as a readable string)
- is used as the photo caption. If the filename starts with a number, it will
- be stripped. For example <code class="docutils literal">03_an_amazing_sunrise.jpg</code> will be render as <em>An amazing sunrise</em>.</p>
- <p>Here is a <a class="reference external" href="/galleries/demo">demo gallery</a> of historic, public domain Nikola
- Tesla pictures taken from <a class="reference external" href="https://kerryr.net/pioneers/gallery/tesla.htm">this site</a>.</p>
- <section id="embedding-images">
- <h2><a class="toc-backref" href="#toc-entry-64" role="doc-backlink">Embedding Images</a></h2>
- <p>Assuming that you have your pictures stored in a folder called <code class="docutils literal">images</code> (as configured above),
- you can embed the same in your posts with the following reST directive:</p>
- <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
- </pre><p>Which is equivalent to the following HTML code:</p>
- <pre class="code html"><a name="rest_code_0fb93ef519964ad4a6c5c27cd7c444b6-1"></a><span class="p"><</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">></span>
- </pre><p>Please take note of the leading forward-slash <code class="docutils literal">/</code> which refers to the root
- output directory. (Make sure to use this even if you’re not deploying to
- web server root.)</p>
- <p>You can also use thumbnails with the <code class="docutils literal">.. thumbnail::</code> reST directive. For
- more details, and equivalent HTML code, see <a class="reference internal" href="#thumbnails">Thumbnails</a>.</p>
- </section>
- </section>
- <section id="handling-exif-data">
- <h1><a class="toc-backref" href="#toc-entry-65" role="doc-backlink">Handling EXIF Data</a></h1>
- <p>Your images contain a certain amount of extra data besides the image itself,
- called the <a class="reference external" href="https://en.wikipedia.org/wiki/Exchangeable_image_file_format">EXIF metadata.</a>
- It contains information about the camera you used to take the picture, when it was taken,
- and maybe even the location where it was taken.</p>
- <p>This is both useful, because you can use it in some apps to locate all the pictures taken
- in a certain place, or with a certain camera, but also, since the pictures Nikola
- publishes are visible to anyone on the Internet, a privacy risk worth considering
- (Imagine if you post pictures taken at home with GPS info, you are publishing your
- home address!)</p>
- <p>Nikola has some support for managing it, so let's go through a few scenarios to
- see which one you prefer.</p>
- <section id="strip-all-exif-data">
- <h2><a class="toc-backref" href="#toc-entry-66" role="doc-backlink">Strip all EXIF data</a></h2>
- <p>Do this if you want to be absolutely sure that no sensitive information should ever leak:</p>
- <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>
- <a name="rest_code_6a59dc109c2349f9b3f26058211d2f38-2"></a><span class="n">EXIF_WHITELIST</span> <span class="o">=</span> <span class="p">{}</span>
- </pre></section>
- <section id="preserve-all-exif-data">
- <h2><a class="toc-backref" href="#toc-entry-67" role="doc-backlink">Preserve all EXIF data</a></h2>
- <p>Do this if you really don't mind people knowing where pictures were taken, or camera settings:</p>
- <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>
- <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>
- </pre></section>
- <section id="preserve-some-exif-data">
- <h2><a class="toc-backref" href="#toc-entry-68" role="doc-backlink">Preserve some EXIF data</a></h2>
- <p>Do this if you really know what you are doing. EXIF data comes separated in a few IFD blocks.
- The most common ones are:</p>
- <dl class="simple">
- <dt>0th</dt>
- <dd><p>Information about the image itself</p>
- </dd>
- <dt>Exif</dt>
- <dd><p>Information about the camera and the image</p>
- </dd>
- <dt>1st</dt>
- <dd><p>Information about embedded thumbnails (usually nothing)</p>
- </dd>
- <dt>thumbnail</dt>
- <dd><p>An embedded thumbnail, in JPEG format (usually nothing)</p>
- </dd>
- <dt>GPS</dt>
- <dd><p>Geolocation information about the image</p>
- </dd>
- <dt>Interop</dt>
- <dd><p>Not too interesting at this point.</p>
- </dd>
- </dl>
- <p>Each IFD in turn contains a number of tags. For example, 0th contains a ImageWidth tag.
- You can tell Nikola exactly which IFDs to keep, and within each IFD, which tags to keep,
- using the EXIF_WHITELIST option.</p>
- <p>Let's see an example:</p>
- <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>
- <a name="rest_code_074d6b8c00034aa88655763ba6018095-2"></a><span class="n">EXIF_WHITELIST</span> <span class="o">=</span> <span class="p">{</span>
- <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>
- <a name="rest_code_074d6b8c00034aa88655763ba6018095-4"></a> <span class="s2">"Interop"</span><span class="p">:</span> <span class="s2">"*"</span><span class="p">,</span>
- <a name="rest_code_074d6b8c00034aa88655763ba6018095-5"></a><span class="p">}</span>
- </pre><p>So, we preserve EXIF data, and the whitelisted IFDs are "0th" and "Interop". That means
- GPS, for example, will be totally deleted.</p>
- <p>Then, for the Interop IFD, we keep everything, and for the 0th IFD we only keep three tags,
- listed there.</p>
- <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>
- </section>
- </section>
- <section id="handling-icc-profiles">
- <h1><a class="toc-backref" href="#toc-entry-69" role="doc-backlink">Handling ICC Profiles</a></h1>
- <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>
- <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>
- <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>
- <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>
- </pre><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>
- </section>
- <section id="post-processing-filters">
- <h1><a class="toc-backref" href="#toc-entry-70" role="doc-backlink">Post Processing Filters</a></h1>
- <p>You can apply post processing to the files in your site, in order to optimize them
- or change them in arbitrary ways. For example, you may want to compress all CSS
- and JS files using yui-compressor.</p>
- <p>To do that, you can use the provided helper adding this in your <code class="docutils literal">conf.py</code>:</p>
- <pre class="code python"><a name="rest_code_42fbfa656d7046b1b4212f89ab8de86f-1"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
- <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>
- <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>
- <a name="rest_code_42fbfa656d7046b1b4212f89ab8de86f-4"></a><span class="p">}</span>
- </pre><p>Where <code class="docutils literal">"filters.yui_compressor"</code> points to a helper function provided by Nikola in the
- <code class="docutils literal">filters</code> module. You can replace that with strings describing command lines, or
- arbitrary python functions.</p>
- <p>If there's any specific thing you expect to be generally useful as a filter, contact
- me and I will add it to the filters library so that more people use it.</p>
- <p>The currently available filters are:</p>
- <aside class="sidebar">
- <p class="sidebar-title">Creating your own filters</p>
- <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>
- and you can use arbitrary Python functions as filters, too.</p>
- <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).
- For example, this is how the yui_compressor filter is implemented:</p>
- <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>
- <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>
- <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>
- </pre><p>You can turn any function into a filter using <code class="docutils literal">apply_to_text_file</code> (for
- text files to be read in UTF-8) and <code class="docutils literal">apply_to_binary_file</code> (for files to
- be read in binary mode).</p>
- <p>As a silly example, this would make everything uppercase and totally break
- your website:</p>
- <pre class="code python"><a name="rest_code_53c8543032bb404882fc332baf04c954-1"></a><span class="kn">import</span> <span class="nn">string</span>
- <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>
- <a name="rest_code_53c8543032bb404882fc332baf04c954-3"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
- <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>
- <a name="rest_code_53c8543032bb404882fc332baf04c954-5"></a><span class="p">}</span>
- </pre></aside>
- <dl>
- <dt>filters.html_tidy_nowrap</dt>
- <dd><p>Prettify HTML 5 documents with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
- </dd>
- <dt>filters.html_tidy_wrap</dt>
- <dd><p>Prettify HTML 5 documents wrapped at 80 characters with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
- </dd>
- <dt>filters.html_tidy_wrap_attr</dt>
- <dd><p>Prettify HTML 5 documents and wrap lines and attributes with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
- </dd>
- <dt>filters.html_tidy_mini</dt>
- <dd><p>Minify HTML 5 into smaller documents with <a class="reference external" href="https://www.html-tidy.org/">tidy5</a></p>
- </dd>
- <dt>filters.html_tidy_withconfig</dt>
- <dd><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>
- </dd>
- <dt>filters.html5lib_minify</dt>
- <dd><p>Minify HTML5 using html5lib_minify</p>
- </dd>
- <dt>filters.html5lib_xmllike</dt>
- <dd><p>Format using html5lib</p>
- </dd>
- <dt>filters.typogrify</dt>
- <dd><p>Improve typography using <a class="reference external" href="https://github.com/mintchaos/typogrify">typogrify</a></p>
- </dd>
- <dt>filters.typogrify_sans_widont</dt>
- <dd><p>Same as typogrify without the widont filter</p>
- </dd>
- <dt>filters.typogrify_custom</dt>
- <dd><p>Run typogrify with a custom set of filters or ignored HTML elements. Takes one or
- 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>
- must be a list of typogrify filter callables to run. <code class="docutils literal">ignore_tags</code> must be a list
- of strings specifying HTML tags, CSS classes (prefixed with <code class="docutils literal">.</code>), tag <code class="docutils literal">id</code> names
- (prefixed with <code class="docutils literal">#</code>), or a tag and a class or id. The following code should be
- placed in <code class="docutils literal">conf.py</code>.</p>
- <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>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-2"></a><span class="kn">import</span> <span class="nn">functools</span>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-3"></a><span class="c1"># This filter will ignore HTML elements with the CSS class "typo-ignore"</span>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-4"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
- <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>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-6"></a><span class="p">}</span>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-7"></a><span class="c1"># Alternatively, to specify ``typogrify_filters``</span>
- <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>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-9"></a><span class="n">FILTERS</span> <span class="o">=</span> <span class="p">{</span>
- <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>
- <a name="rest_code_cff929451ecd4fadacb070fa7e63e5a6-11"></a><span class="p">}</span>
- </pre><p>The default value for <code class="docutils literal">typogrify_filters</code> is
- <code class="docutils literal">[typo.amp, typo.widont, typo.smartypants, typo.caps, typo.initial_quotes]</code> and the
- 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
- specified, the default tags will be appended to the supplied list. See the
- <a class="reference external" href="https://github.com/mintchaos/typogrify/blob/master/typogrify/filters.py#L8-L14">documentation</a>
- for the <code class="docutils literal">process_ignores</code> function in typogrify.</p>
- </dd>
- <dt>filters.minify_lines</dt>
- <dd><p><strong>THIS FILTER HAS BEEN TURNED INTO A NOOP</strong> and currently does nothing.</p>
- </dd>
- <dt>filters.normalize_html</dt>
- <dd><p>Pass HTML through LXML to normalize it. For example, it will resolve <code class="docutils literal">&quot;</code> to actual
- quotes. Usually not needed.</p>
- </dd>
- <dt>filters.yui_compressor</dt>
- <dd><p>Compress CSS/JavaScript using <a class="reference external" href="https://yui.github.io/yuicompressor/">YUI compressor</a></p>
- </dd>
- <dt>filters.closure_compiler</dt>
- <dd><p>Compile, compress, and optimize JavaScript <a class="reference external" href="https://developers.google.com/closure/compiler/">Google Closure Compiler</a></p>
- </dd>
- <dt>filters.optipng</dt>
- <dd><p>Compress PNG files using <a class="reference external" href="http://optipng.sourceforge.net/">optipng</a></p>
- </dd>
- <dt>filters.jpegoptim</dt>
- <dd><p>Compress JPEG files using <a class="reference external" href="https://www.kokkonen.net/tjko/projects.html">jpegoptim</a></p>
- </dd>
- <dt>filters.cssminify</dt>
- <dd><p>Minify CSS using <a class="reference external" href="https://cssminifier.com/">https://cssminifier.com/</a> (requires Internet access)</p>
- </dd>
- <dt>filters.jsminify</dt>
- <dd><p>Minify JS using <a class="reference external" href="https://javascript-minifier.com/">https://javascript-minifier.com/</a> (requires Internet access)</p>
- </dd>
- <dt>filters.jsonminify</dt>
- <dd><p>Minify JSON files (strip whitespace and use minimal separators).</p>
- </dd>
- <dt>filters.xmlminify</dt>
- <dd><p>Minify XML files. Suitable for Nikola’s sitemaps and Atom feeds.</p>
- </dd>
- <dt>filters.add_header_permalinks</dt>
- <dd><p>Add links next to every header, Sphinx-style. You will need to add styling for the <cite>headerlink</cite> class,
- in <cite>custom.css</cite>, for example:</p>
- <pre class="code css"><a name="rest_code_23a0b8e4e225420e91637d0a55452b18-1"></a><span class="c">/* Header permalinks */</span>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-6"></a><span class="p">}</span>
- <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-7"></a>
- <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-8"></a><span class="p">.</span><span class="nc">headerlink</span> <span class="p">{</span>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-13"></a><span class="p">}</span>
- <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-14"></a>
- <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>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_23a0b8e4e225420e91637d0a55452b18-20"></a><span class="p">}</span>
- </pre><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).
- 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>
- <pre class="code python"><a name="rest_code_aee967f647e14195b882cad72e443193-1"></a><span class="c1"># Default value:</span>
- <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>
- <a name="rest_code_aee967f647e14195b882cad72e443193-3"></a><span class="c1"># Include *every* header (not recommended):</span>
- <a name="rest_code_aee967f647e14195b882cad72e443193-4"></a><span class="c1"># HEADER_PERMALINKS_XPATH_LIST = ['*//{hx}']</span>
- </pre></dd>
- <dt>filters.deduplicate_ids</dt>
- <dd><p>Prevent duplicated IDs in HTML output. An incrementing counter is added to
- offending IDs. If used alongside <code class="docutils literal">add_header_permalinks</code>, it will fix
- those links (it must run <strong>after</strong> that filter)</p>
- <p>IDs are numbered from the bottom up, which is useful for indexes (updates
- appear at the top). There are exceptions, which may be configured using
- <code class="docutils literal">DEDUPLICATE_IDS_TOP_CLASSES</code> — if any of those classes appears sin the
- document, the IDs are rewritten top-down, which is useful for posts/pages
- (updates appear at the bottom).</p>
- <p>Note that in rare cases, permalinks might not always be <em>permanent</em> in case
- of edits.</p>
- <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>
- </pre><p>You can also use a file blacklist (<code class="docutils literal">HEADER_PERMALINKS_FILE_BLACKLIST</code>),
- useful for some index pages. Paths include the output directory (eg.
- <code class="docutils literal">output/index.html</code>)</p>
- </dd>
- </dl>
- <p>You can apply filters to specific posts or pages by using the <code class="docutils literal">filters</code> metadata field:</p>
- <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>
- </pre><p>Please note that applying custom filters (not those provided via Nikola's filter module)
- via metadata only works for filters implemented via external programs like in that <cite>sed</cite> example.</p>
- </section>
- <section id="optimizing-your-website">
- <h1><a class="toc-backref" href="#toc-entry-71" role="doc-backlink">Optimizing Your Website</a></h1>
- <p>One of the main goals of Nikola is to make your site fast and light. So here are a few
- tips we have found when setting up Nikola with Apache. If you have more, or
- different ones, or about other web servers, please share!</p>
- <ol class="arabic">
- <li><p>Use a speed testing tool. I used Yahoo's YSlow but you can use any of them, and
- it's probably a good idea to use more than one.</p></li>
- <li><p>Enable compression in Apache:</p>
- <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
- </pre></li>
- <li><p>If even after you did the previous step the CSS files are not sent compressed:</p>
- <pre class="code apache"><a name="rest_code_35580c9bfd29414aa75d002cc8b6dd19-1"></a><span class="nb">AddType</span> text/css .css
- </pre></li>
- <li><p>Optionally you can create static compressed copies and save some CPU on your server
- with the GZIP_FILES option in Nikola.</p></li>
- <li><p>The bundles Nikola plugin can drastically decrease the number of CSS and JS files your site fetches.</p></li>
- <li><p>Through the filters feature, you can run your files through arbitrary commands, so that images
- are recompressed, JavaScript is minimized, etc.</p></li>
- <li><p>The USE_CDN option offloads standard JavaScript and CSS files to a CDN so they are not
- downloaded from your server.</p></li>
- </ol>
- </section>
- <section id="math">
- <h1><a class="toc-backref" href="#toc-entry-72" role="doc-backlink">Math</a></h1>
- <p>Nikola supports math input via MathJax (by default) or KaTeX. It is activated
- via the math roles and directives of reStructuredText and the usual LaTeX
- delimiters for other input formats.</p>
- <section id="configuration-1">
- <h2><a class="toc-backref" href="#toc-entry-73" role="doc-backlink">Configuration</a></h2>
- <p>Nikola uses MathJax by default. If you want to use KaTeX (faster and prettier,
- but may not support every feature yet), set <code class="docutils literal">USE_KATEX = True</code> in
- <code class="docutils literal">conf.py</code>.</p>
- <p>To use mathematics in a post, you <strong>must</strong> set the <code class="docutils literal">has_math</code> metadata field
- to <code class="docutils literal">true</code>. (Exception: posts that are Jupyter Notebooks are automatically
- marked as math)</p>
- <!-- Note to editors: the paragraph below uses U+200B, zero-width space. Don’t break it. -->
- <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
- <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
- (which may conflict with running text!), you need to use special config for
- your renderer:</p>
- <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>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-2"></a><span class="s2"><script type="text/x-mathjax-config"></span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-3"></a><span class="s2">MathJax.Hub.Config({</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-4"></a><span class="s2"> tex2jax: {</span>
- <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>
- <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>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-7"></a><span class="s2"> processEscapes: true</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-8"></a><span class="s2"> },</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-9"></a><span class="s2"> displayAlign: 'center', // Change this to 'left' if you want left-aligned equations.</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-10"></a><span class="s2"> "HTML-CSS": {</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-11"></a><span class="s2"> styles: {'.MathJax_Display': {"margin": 0}}</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-12"></a><span class="s2"> }</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-13"></a><span class="s2">});</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-14"></a><span class="s2"></script></span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-15"></a><span class="s2">"""</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-16"></a>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-17"></a><span class="n">KATEX_AUTO_RENDER</span> <span class="o">=</span> <span class="s2">"""</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-18"></a><span class="s2">delimiters: [</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-19"></a><span class="s2"> {left: "$$", right: "$$", display: true},</span>
- <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>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-21"></a><span class="s2"> {left: "$", right: "$", display: false},</span>
- <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>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-23"></a><span class="s2">]</span>
- <a name="rest_code_29a2de419c9648389ff48384089335bd-24"></a><span class="s2">"""</span>
- </pre><p><em>(Note: the previous paragraph uses invisible characters to prevent rendering
- TeX for display, so don’t copy the examples with three dots to your posts)</em></p>
- </section>
- <section id="inline-usage">
- <h2><a class="toc-backref" href="#toc-entry-74" role="doc-backlink">Inline usage</a></h2>
- <p>Inline mathematics are produced using the reST <cite>math</cite> <strong>role</strong> or the LaTeX
- backslash-parentheses delimiters:</p>
- <p>Euler’s formula: <span class="math">\(e^{ix} = \cos x + i\sin x\)</span></p>
- <p>In reST:</p>
- <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>
- </pre><p>In HTML and other input formats:</p>
- <pre class="code text"><a name="rest_code_19376130ec434673a2686d863af80f81-1"></a>Euler’s formula: \(e^{ix} = \cos x + i\sin x\)
- </pre><p>Note that some input formats (including Markdown) require using <strong>double
- backslashes</strong> in the delimiters (<code class="docutils literal"><span class="pre">\\(inline</span> <span class="pre">math\\)</span></code>). Please check your
- output first before reporting bugs.</p>
- </section>
- <section id="display-usage">
- <h2><a class="toc-backref" href="#toc-entry-75" role="doc-backlink">Display usage</a></h2>
- <p>Display mathematics are produced using the reST <cite>math</cite> <strong>directive</strong> or the
- LaTeX backslash-brackets delimiters:</p>
- <div class="math">
- \begin{equation*}
- \int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C
- \end{equation*}
- </div>
- <p>In reST:</p>
- <pre class="code restructuredtext"><a name="rest_code_88948d9bd8b54c61a22e272d07beea37-1"></a><span class="p">..</span> <span class="ow">math</span><span class="p">::</span>
- <a name="rest_code_88948d9bd8b54c61a22e272d07beea37-2"></a>
- <a name="rest_code_88948d9bd8b54c61a22e272d07beea37-3"></a> \int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C
- </pre><p>In HTML and other input formats:</p>
- <pre class="code text"><a name="rest_code_7373f5fae80e40eaab5a3acb15d8c46d-1"></a>\[\int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C\]
- </pre><p>Note that some input formats (including Markdown) require using <strong>double
- backslashes</strong> in the delimiters (<code class="docutils literal"><span class="pre">\\[display</span> <span class="pre">math\\]</span></code>). Please check your
- output first before reporting bugs.</p>
- </section>
- </section>
- <section id="restructuredtext-extensions">
- <h1><a class="toc-backref" href="#toc-entry-76" role="doc-backlink">reStructuredText Extensions</a></h1>
- <p>Nikola includes support for a few directives and roles that are not part of docutils, but which
- we think are handy for website development.</p>
- <section id="includes">
- <h2><a class="toc-backref" href="#toc-entry-77" role="doc-backlink">Includes</a></h2>
- <p>Nikola supports the standard reStructuredText <code class="docutils literal">include</code> directive, but with a
- catch: filenames are relative to <strong>Nikola site root</strong> (directory with <code class="docutils literal">conf.py</code>)
- instead of the post location (eg. <code class="docutils literal">posts/</code> directory)!</p>
- </section>
- <section id="media">
- <h2><a class="toc-backref" href="#toc-entry-78" role="doc-backlink">Media</a></h2>
- <p>This directive lets you embed media from a variety of sites automatically by just passing the
- URL of the page. For example here are two random videos:</p>
- <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
- <a name="rest_code_f6d1a5d2b5de4fe9b25f343315effd28-2"></a>
- <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
- </pre><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>
- </section>
- <section id="youtube">
- <h2><a class="toc-backref" href="#toc-entry-79" role="doc-backlink">YouTube</a></h2>
- <p>To link to a YouTube video, you need the id of the video. For example, if the
- 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
- <strong>8N_tupPBtWQ</strong></p>
- <p>Once you have that, all you need to do is:</p>
- <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
- </pre><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>,
- <code class="docutils literal">center</code>, <code class="docutils literal">right</code>) — all are optional. Example:</p>
- <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
- <a name="rest_code_5994c24194594903af696e19e15a8ff1-2"></a> <span class="nc">:align:</span> center
- <a name="rest_code_5994c24194594903af696e19e15a8ff1-3"></a> <span class="nc">:start_at:</span> 4
- </pre></section>
- <section id="vimeo">
- <h2><a class="toc-backref" href="#toc-entry-80" role="doc-backlink">Vimeo</a></h2>
- <p>To link to a Vimeo video, you need the id of the video. For example, if the
- 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>
- <p>Once you have that, all you need to do is:</p>
- <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
- </pre><p>If you have internet connectivity when generating your site, the height and width of
- the embedded player will be set to the native height and width of the video.
- You can override this if you wish:</p>
- <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
- <a name="rest_code_e750474411fd41399d4465d25eef43da-2"></a> <span class="nc">:height:</span> 240
- <a name="rest_code_e750474411fd41399d4465d25eef43da-3"></a> <span class="nc">:width:</span> 320
- </pre><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>,
- <code class="docutils literal">center</code>, <code class="docutils literal">right</code>) — all are optional.</p>
- </section>
- <section id="soundcloud">
- <h2><a class="toc-backref" href="#toc-entry-81" role="doc-backlink">Soundcloud</a></h2>
- <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
- ID for the piece, which you can find in the "share" link. For example, if the
- WordPress code starts like this:</p>
- <pre class="code text"><a name="rest_code_16d563c463994e79bf7433a77969079e-1"></a>[soundcloud url="http://api.soundcloud.com/tracks/78131362" …/]
- </pre><p>The ID is 78131362 and you can embed the audio with this:</p>
- <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
- </pre><p>You can also embed playlists, via the <cite>soundcloud_playlist</cite> directive which works the same way.</p>
- <blockquote>
- <div class="soundcloud-player">
- <iframe width="600" height="160"
- scrolling="no" frameborder="no"
- src="https://w.soundcloud.com/player/?url=http://api.soundcloud.com/playlists/9411706">
- </iframe>
- </div></blockquote>
- <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>,
- <code class="docutils literal">center</code>, <code class="docutils literal">right</code>) — all are optional.</p>
- </section>
- <section id="code">
- <h2><a class="toc-backref" href="#toc-entry-82" role="doc-backlink">Code</a></h2>
- <p>The <code class="docutils literal">code</code> directive has been included in docutils since version 0.9 and now
- replaces Nikola's <code class="docutils literal"><span class="pre">code-block</span></code> directive. To ease the transition, two aliases
- 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>
- <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
- <a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-2"></a> <span class="nc">:number-lines:</span>
- <a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-3"></a>
- <a name="rest_code_51f5562a23bc486d8d9af238e5a1990d-4"></a> print("Our virtues and our failings are inseparable")
- </pre><p>Certain lines might be highlighted via the <code class="docutils literal"><span class="pre">emphasize-lines</span></code> directive:</p>
- <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
- <a name="rest_code_011532fe246d403689684094a3044cc0-2"></a> <span class="nc">:emphasize-lines:</span> 3,5
- <a name="rest_code_011532fe246d403689684094a3044cc0-3"></a>
- <a name="rest_code_011532fe246d403689684094a3044cc0-4"></a> def some_function():
- <a name="rest_code_011532fe246d403689684094a3044cc0-5"></a> interesting = False
- <a name="rest_code_011532fe246d403689684094a3044cc0-6"></a> print('This line is highlighted.')
- <a name="rest_code_011532fe246d403689684094a3044cc0-7"></a> print('This one is not...')
- <a name="rest_code_011532fe246d403689684094a3044cc0-8"></a> print('...but this one is.')
- </pre><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>
- </section>
- <section id="listing">
- <h2><a class="toc-backref" href="#toc-entry-83" role="doc-backlink">Listing</a></h2>
- <p>To use this, you have to put your source code files inside <code class="docutils literal">listings</code> or whatever folders
- 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>
- inside one of these folders:</p>
- <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
- </pre><p>Will include the source code from <code class="docutils literal">foo.py</code>, highlight its syntax in python mode,
- and also create a <code class="docutils literal">listings/foo.py.html</code> page (or in another directory, depending on
- <code class="docutils literal">LISTINGS_FOLDER</code>) and the listing will have a title linking to it.</p>
- <p>The stand-alone <code class="docutils literal">listings/</code> pages also support Jupyter notebooks, if they are
- supported site-wide. You must have something for <code class="docutils literal">.ipynb</code> in POSTS or PAGES
- for the feature to work.</p>
- <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
- various options for controlling which parts of the file are included), and also
- a <code class="docutils literal">linenos</code> option for Sphinx compatibility.</p>
- <p>The <code class="docutils literal">LISTINGS_FOLDER</code> configuration variable allows to specify a list of folders where
- to fetch listings from together with subfolder of the <code class="docutils literal">output</code> folder where the
- processed listings should be put in. The default is, <code class="docutils literal">LISTINGS_FOLDERS = {'listings': 'listings'}</code>,
- 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>.
- Extending <code class="docutils literal">LISTINGS_FOLDERS</code> to <code class="docutils literal">{'listings': 'listings', 'code': <span class="pre">'formatted-code'}</span></code>
- will additionally process all source code files in <code class="docutils literal">code</code> and put the results into
- <code class="docutils literal"><span class="pre">output/formatted-code</span></code>.</p>
- <aside class="admonition note">
- <p class="admonition-title">Note</p>
- <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,
- 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>
- 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
- <code class="docutils literal"><span class="pre">end-line</span></code>.</p>
- </aside>
- </section>
- <section id="gist">
- <h2><a class="toc-backref" href="#toc-entry-84" role="doc-backlink">Gist</a></h2>
- <p>You can easily embed GitHub gists with this directive, like this:</p>
- <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
- </pre><p>Producing this:</p>
- <script src="https://gist.github.com/2395294.js"></script><noscript><pre class="literal-block">#include <stdlib.h>
- #include <stdio.h>
-
- int nonHeapInt;
-
- struct HeapObject
- {
- int x; // 因為如果找 x 的 pointer,實際上和找 HeapObject 的開頭 pointer 相同,
- // 所以我們必需加一個y,讓我們指定 pointer 時不會指到 HeapObject 的開頭。
- int y;
- };
-
- int main()
- {
- struct HeapObject * heapObject = malloc(sizeof(struct HeapObject));
-
- nonHeapInt = 10;
- heapObject->y = 20;
-
- printf("Start nonHeapInt:%d\n", nonHeapInt);
- printf("Start heapObject->y:%d\n", heapObject->y);
-
- // free(&nonHeapInt); // GCC 會警告,執行 glibc 會丟 invalid pointer exception
- // free(&(heapObject->y)); // 雖然不會景告,但 glibc 還是會丟 invalid pointer exception
-
- printf("End nonHeapInt:%d\n", nonHeapInt);
- printf("End heapObject->y:%d\n", heapObject->y);
-
- }
- </pre>
- </noscript><p>This degrades gracefully if the browser doesn't support JavaScript.</p>
- </section>
- <section id="thumbnails">
- <h2><a class="toc-backref" href="#toc-entry-85" role="doc-backlink">Thumbnails</a></h2>
- <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
- <code class="docutils literal">thumbnail</code> directive, like this:</p>
- <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
- <a name="rest_code_549bffe9692c4ad7a4f4389128d42fa3-2"></a> <span class="nc">:alt:</span> Nikola Tesla
- </pre><p>The small thumbnail will be placed in the page, and it will be linked to the bigger
- version of the image when clicked, using
- <a class="reference external" href="https://feimosi.github.io/baguetteBox.js/">baguetteBox</a> by default. All options supported by
- the reST <a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#image">image</a>
- directive are supported (except <code class="docutils literal">target</code>). Providing <code class="docutils literal">alt</code> is recommended,
- as this is the image caption. If a body element is provided, the thumbnail will
- mimic the behavior of the <a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure">figure</a>
- directive instead:</p>
- <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
- <a name="rest_code_37a0e080ea93497691ca445acb69483e-2"></a> <span class="nc">:alt:</span> Nikola Tesla
- <a name="rest_code_37a0e080ea93497691ca445acb69483e-3"></a>
- <a name="rest_code_37a0e080ea93497691ca445acb69483e-4"></a> Nikola Tesla, the man that invented the 20th century.
- </pre><p>If you want to include a thumbnail in a non-reST post, you need to produce at
- least this basic HTML:</p>
- <pre class="code html"><a name="rest_code_4fdc06777c7b4e77808ecc29f6a6f728-1"></a><span class="p"><</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">><</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">></</span><span class="nt">a</span><span class="p">></span>
- </pre></section>
- <section id="chart">
- <h2><a class="toc-backref" href="#toc-entry-86" role="doc-backlink">Chart</a></h2>
- <p>This directive is a thin wrapper around <a class="reference external" href="http://pygal.org/">Pygal</a> and will produce charts
- as SVG files embedded directly in your pages.</p>
- <p>Here's an example of how it works:</p>
- <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
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-2"></a> <span class="nc">:title:</span> 'Browser usage evolution (in %)'
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-3"></a> <span class="nc">:x_labels:</span> ["2002", "2003", "2004", "2005", "2006", "2007"]
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-4"></a>
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-5"></a> 'Firefox', [None, None, 0, 16.6, 25, 31]
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-6"></a> 'Chrome', [None, None, None, None, None, None]
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-7"></a> 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
- <a name="rest_code_e5fca258a8004eb1b5c935b4651c858d-8"></a> 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
- </pre><p>The argument passed next to the directive (Bar in that example) is the type of chart, and can be one of
- Line, StackedLine, Bar, StackedBar, HorizontalBar, XY, DateY, Pie, Radar, Dot, Funnel, Gauge, Pyramid. For
- 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>
- <p>It can take <em>a lot</em> of options to let you customize the charts (in the example, title and x_labels).
- 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>
- <p>Finally, the content of the directive is the actual data, in the form of a label and
- a list of values, one series per line.</p>
- <p>You can also specify a <code class="docutils literal">:data_file:</code> option as described in the documentation for the chart shortcut.</p>
- </section>
- <section id="doc">
- <h2><a class="toc-backref" href="#toc-entry-87" role="doc-backlink">Doc</a></h2>
- <p>This role is useful to make links to other post or page inside the same site.</p>
- <p>Here's an example:</p>
- <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 <creating-a-theme>`</span> about theme creating.
- </pre><p>In this case we are giving the portion of text we want to link. So, the result will be:</p>
- <blockquote>
- <p>Take a look at <a class="reference external" href="/pages/creating-a-theme.html">my other post</a> about theme creating.</p>
- </blockquote>
- <p>If we want to use the post's title as the link's text, just do:</p>
- <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.
- </pre><p>and it will produce:</p>
- <blockquote>
- <p>Take a look at <a class="reference external" href="/pages/creating-a-theme.html">Creating a Theme</a> to know how to do it.</p>
- </blockquote>
- <p>The reference in angular brackets should be the <cite>slug</cite> for the target page. It supports a fragment, so
- things like <code class="docutils literal"><span class="pre"><creating-a-theme#starting-from-somewhere></span></code> should work. You can also use the title, and
- Nikola will slugify it for you, so <code class="docutils literal">Creating a theme</code> is also supported.</p>
- <p>Keep in mind that the important thing is the slug. No attempt is made to check if the fragment points to
- an existing location in the page, and references that don't match any page's slugs will cause warnings.</p>
- </section>
- <section id="post-list">
- <h2><a class="toc-backref" href="#toc-entry-88" role="doc-backlink">Post List</a></h2>
- <aside class="admonition warning">
- <p class="admonition-title">Warning</p>
- <p>Any post or page that uses this directive will be considered out of date,
- every time a post is added or deleted, causing maybe unnecessary rebuilds.</p>
- <p>On the other hand, it will sometimes <strong>not</strong> be considered out of date if
- a post content changes, so it can sometimes be shown outdated, in those
- cases, use <code class="docutils literal">nikola build <span class="pre">-a</span></code> to force a total rebuild.</p>
- </aside>
- <p>This directive can be used to generate a list of posts. You could use it, for
- example, to make a list of the latest 5 blog posts, or a list of all blog posts
- with the tag <code class="docutils literal">nikola</code>:</p>
- <pre class="code restructuredtext"><a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-1"></a>Here are my 5 latest and greatest blog posts:
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-2"></a>
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-3"></a><span class="p">..</span> <span class="ow">post-list</span><span class="p">::</span>
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-4"></a> <span class="nc">:stop:</span> 5
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-5"></a>
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-6"></a>These are all my posts about Nikola:
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-7"></a>
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-8"></a><span class="p">..</span> <span class="ow">post-list</span><span class="p">::</span>
- <a name="rest_code_1fd4a24ebd0346c18850db884f8b1c5b-9"></a> <span class="nc">:tags:</span> nikola
- </pre><p>Using shortcode syntax (for other compilers):</p>
- <pre class="code text"><a name="rest_code_7897e663e40d4ffdb57699fb19e12cb0-1"></a>{{% post-list stop=5 %}}{{% /post-list %}}
- </pre><p>The following options are recognized:</p>
- <ul class="simple">
- <li><dl class="simple">
- <dt><code class="docutils literal">start</code><span class="classifier">integer</span></dt>
- <dd><p>The index of the first post to show.
- A negative value like <code class="docutils literal"><span class="pre">-3</span></code> will show the <em>last</em> three posts in the
- post-list.
- Defaults to None.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">stop</code><span class="classifier">integer</span></dt>
- <dd><p>The index of the last post to show.
- A value negative value like <code class="docutils literal"><span class="pre">-1</span></code> will show every post, but not the
- <em>last</em> in the post-list.
- Defaults to None.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">reverse</code><span class="classifier">flag</span></dt>
- <dd><p>Reverse the order of the post-list.
- Defaults is to not reverse the order of posts.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">sort</code>: string</dt>
- <dd><p>Sort post list by one of each post's attributes, usually <code class="docutils literal">title</code> or a
- custom <code class="docutils literal">priority</code>. Defaults to None (chronological sorting).</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">date</code>: string</dt>
- <dd><p>Show posts that match date range specified by this option. Format:</p>
- <ul>
- <li><p>comma-separated clauses (AND)</p></li>
- <li><dl class="simple">
- <dt>clause: attribute comparison_operator value (spaces optional)</dt>
- <dd><ul>
- <li><p>attribute: year, month, day, hour, month, second, weekday, isoweekday; or empty for full datetime</p></li>
- <li><p>comparison_operator: == != <= >= < ></p></li>
- <li><p>value: integer, 'now', 'today', or dateutil-compatible date input</p></li>
- </ul>
- </dd>
- </dl>
- </li>
- </ul>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">tags</code><span class="classifier">string [, string...]</span></dt>
- <dd><p>Filter posts to show only posts having at least one of the <code class="docutils literal">tags</code>.
- Defaults to None.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">require_all_tags</code><span class="classifier">flag</span></dt>
- <dd><p>Change tag filter behaviour to show only posts that have all specified <code class="docutils literal">tags</code>.
- Defaults to False.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">categories</code><span class="classifier">string [, string...]</span></dt>
- <dd><p>Filter posts to show only posts having one of the <code class="docutils literal">categories</code>.
- Defaults to None.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">slugs</code><span class="classifier">string [, string...]</span></dt>
- <dd><p>Filter posts to show only posts having at least one of the <code class="docutils literal">slugs</code>.
- Defaults to None.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">post_type</code> (or <code class="docutils literal">type</code>)<span class="classifier">string</span></dt>
- <dd><p>Show only <code class="docutils literal">posts</code>, <code class="docutils literal">pages</code> or <code class="docutils literal">all</code>.
- Replaces <code class="docutils literal">all</code>. Defaults to <code class="docutils literal">posts</code>.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">all</code><span class="classifier">flag</span></dt>
- <dd><p>(deprecated, use <code class="docutils literal">post_type</code> instead)
- Shows all posts and pages in the post list. Defaults to show only posts.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">lang</code><span class="classifier">string</span></dt>
- <dd><p>The language of post <em>titles</em> and <em>links</em>.
- Defaults to default language.</p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">template</code><span class="classifier">string</span></dt>
- <dd><p>The name of an alternative template to render the post-list.
- Defaults to <code class="docutils literal">post_list_directive.tmpl</code></p>
- </dd>
- </dl>
- </li>
- <li><dl class="simple">
- <dt><code class="docutils literal">id</code><span class="classifier">string</span></dt>
- <dd><p>A manual id for the post list.
- Defaults to a random name composed by <code class="docutils literal">'post_list_' + <span class="pre">uuid.uuid4().hex</span></code>.</p>
- </dd>
- </dl>
- </li>
- </ul>
- <p>The post list directive uses the <code class="docutils literal">post_list_directive.tmpl</code> template file (or
- another one, if you use the <code class="docutils literal">template</code> option) to generate the list's HTML. By
- default, this is an unordered list with dates and clickable post titles. See
- the template file in Nikola's base theme for an example of how this works.</p>
- <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
- the appropriate path if this happens.</p>
- <p>We recommend using pages with dates in the past (1970-01-01) to avoid
- dependency issues.</p>
- <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
- with a <code class="docutils literal">True</code> argument, eg. <code class="docutils literal">all=True</code>.</p>
- <aside class="sidebar">
- <p class="sidebar-title">Docutils Configuration</p>
- <p>ReStructured Text is "compiled" by docutils, which supports a number of
- configuration options. It would be difficult to integrate them all into
- Nikola's configuration, so you can just put a <code class="docutils literal">docutils.conf</code> next
- 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>
- <p>More information in the <a class="reference external" href="https://docutils.sourceforge.io/docs/user/config.html">docutils configuration reference</a></p>
- </aside>
- </section>
- </section>
- <section id="importing-your-wordpress-site-into-nikola">
- <h1><a class="toc-backref" href="#toc-entry-89" role="doc-backlink">Importing your WordPress site into Nikola</a></h1>
- <p>If you like Nikola, and want to start using it, but you have a WordPress blog, Nikola
- supports importing it. Here are the steps to do it:</p>
- <ol class="arabic simple">
- <li><p>Get an XML dump of your site <a class="footnote-reference brackets" href="#footnote-1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></li>
- <li><p><code class="docutils literal">nikola import_wordpress <span class="pre">mysite.wordpress.2012-12-20.xml</span></code></p></li>
- </ol>
- <p>After some time, this will create a <code class="docutils literal">new_site</code> folder with all your data. It currently supports
- the following:</p>
- <ul>
- <li><p>All your posts and pages</p></li>
- <li><p>Keeps “draft” status</p></li>
- <li><p>Your tags and categories</p></li>
- <li><p>Imports your attachments and fixes links to point to the right places</p></li>
- <li><p>Will try to add redirects that send the old post URLs to the new ones</p></li>
- <li><p>Will give you a URL map so you know where each old post was</p>
- <p>This is also useful for DISQUS thread migration, or server-based 301
- redirects!</p>
- </li>
- <li><p>Allows you to export your comments with each post</p></li>
- <li><p>Exports information on attachments per post</p></li>
- <li><p>There are different methods to transfer the content of your posts:</p>
- <ul>
- <li><p>You can convert them to HTML with the WordPress page compiler plugin
- for Nikola. This will format the posts including supported shortcodes
- the same way as WordPress does. Use the <code class="docutils literal"><span class="pre">--transform-to-html</span></code> option
- to convert your posts to HTML.</p>
- <p>If you use this option, you do not need to install the plugin
- permanently. You can ask Nikola to install the plugin into the subdirectory
- <code class="docutils literal">plugins</code> of the current working directory by specifying
- the <code class="docutils literal"><span class="pre">--install-wordpress-compiler</span></code> option.</p>
- </li>
- <li><p>You can leave the posts the way they are and use the WordPress page
- compiler plugin to render them when building your new blog. This also
- allows you to create new posts using the WordPress syntax, or to manually
- add more shortcode plugins later. Use the <code class="docutils literal"><span class="pre">--use-wordpress-compiler</span></code>
- option to not touch your posts.</p>
- <p>If you want to use this option, you have to install the plugin permanently.
- You can ask Nikola to install the plugin into your new site by specifying
- the <code class="docutils literal"><span class="pre">--install-wordpress-compiler</span></code> option.</p>
- </li>
- <li><p>You can let Nikola convert your posts to Markdown. This is <em>not</em> error
- free, because WordPress uses some unholy mix of HTML and strange things.
- This is the default option and requires no plugins.</p></li>
- </ul>
- <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,
- <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>
- in the last case if you need to edit or fix any of them.</p>
- <p>Please note that the page compiler currently only supports the <code class="docutils literal">[code]</code> shortcode,
- but other shortcodes can be supported via plugins.</p>
- <p>Also note that the WordPress page compiler is licensed under GPL v2 since
- it uses code from WordPress itself, while Nikola is licensed under the more
- liberal MIT license.</p>
- </li>
- </ul>
- <p>This feature is a work in progress, and the only way to improve it is to have it used for
- as many sites as possible and make it work better each time, so we are happy to get requests
- about it.</p>
- <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="#footnote-reference-1">1</a><span class="fn-bracket">]</span></span>
- <p>The dump needs to be in 1.2 format. You can check by reading it, it should say
- <code class="docutils literal"><span class="pre">xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"</span></code> near the top of the
- 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
- WordPress before dumping.</p>
- <p>Other versions may or may not work.</p>
- </aside>
- </aside>
- <section id="importing-to-a-custom-location-or-into-an-existing-site">
- <h2><a class="toc-backref" href="#toc-entry-90" role="doc-backlink">Importing to a custom location or into an existing site</a></h2>
- <p>It is possible to either import into a location you desire or into an already existing Nikola site.
- To do so you can specify a location after the dump:</p>
- <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
- </pre><p>With this command Nikola will import into the folder <code class="docutils literal">import_location</code>.</p>
- <p>If the folder already exists Nikola will not overwrite an existing <code class="docutils literal">conf.py</code>.
- Instead a new file with a timestamp at the end of the filename will be created.</p>
- </section>
- </section>
- <section id="using-twitter-cards">
- <h1><a class="toc-backref" href="#toc-entry-91" role="doc-backlink">Using Twitter Cards</a></h1>
- <p>Nikola supports Twitter Card summaries, but they are disabled by default.</p>
- <p>Twitter Cards enable you to show additional information in Tweets that link
- to your content.
- Nikola supports <a class="reference external" href="https://dev.twitter.com/docs/cards">Twitter Cards</a>.
- They are implemented to use <em>Open Graph</em> tags whenever possible.</p>
- <p>Images displayed come from the <cite>previewimage</cite> meta tag.</p>
- <p>You can specify the card type by using the <cite>card</cite> parameter in TWITTER_CARD.</p>
- <p>To enable and configure your use of Twitter Cards, please modify the
- corresponding lines in your <code class="docutils literal">conf.py</code>:</p>
- <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>
- <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>
- <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>
- <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-4"></a> <span class="c1"># see https://dev.twitter.com/cards/types</span>
- <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>
- <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>
- <a name="rest_code_d103c0710e8c4cf098b7a7ddaa447a36-7"></a><span class="p">}</span>
- </pre></section>
- <section id="custom-plugins">
- <h1><a class="toc-backref" href="#toc-entry-92" role="doc-backlink">Custom Plugins</a></h1>
- <p>You can create your own plugins (see <a class="reference external" href="/pages/extending.html">Extending Nikola</a>) and use them in your own
- site by putting them in a <code class="docutils literal">plugins/</code> folder. You can also put them in
- directories listed in the <code class="docutils literal">EXTRA_PLUGINS_DIRS</code> configuration variable.</p>
- </section>
- <section id="getting-extra-plugins">
- <h1><a class="toc-backref" href="#toc-entry-93" role="doc-backlink">Getting Extra Plugins</a></h1>
- <p>If you want extra plugins, there is also the <a class="reference external" href="https://plugins.getnikola.com/">Plugins Index</a>.</p>
- <p>Similarly to themes, there is a nice, built-in command to manage them —
- <code class="docutils literal">plugin</code>:</p>
- <pre class="code console"><a name="rest_code_3afc51eaae9249348be77faf328a4711-1"></a><span class="gp">$</span> nikola plugin -l
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-2"></a><span class="go">Plugins:</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-3"></a><span class="go">--------</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-4"></a><span class="go">helloworld</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-5"></a><span class="go">tags</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-6"></a><span class="go">⋮</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-7"></a><span class="go">⋮</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-8"></a>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-9"></a><span class="gp">$</span> nikola plugin --install helloworld
- <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>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-11"></a><span class="go">[2013-10-12T16:51:58Z] NOTICE: install_plugin: Extracting: helloworld into plugins</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-12"></a><span class="go">plugins/helloworld/requirements.txt</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-13"></a><span class="go">[2013-10-12T16:51:58Z] NOTICE: install_plugin: This plugin has Python dependencies.</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-14"></a><span class="go">[2013-10-12T16:51:58Z] NOTICE: install_plugin: Installing dependencies with pip...</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-15"></a><span class="go">⋮</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-16"></a><span class="go">⋮</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-17"></a><span class="go">[2013-10-12T16:51:59Z] NOTICE: install_plugin: Dependency installation succeeded.</span>
- <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>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-19"></a><span class="go">Contents of the conf.py.sample file:</span>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-20"></a>
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-21"></a><span class="gp"> #</span> Should the Hello World plugin say “BYE” instead?
- <a name="rest_code_3afc51eaae9249348be77faf328a4711-22"></a><span class="go"> BYE_WORLD = False</span>
- </pre><p>Then you also can uninstall your plugins:</p>
- <pre class="code console"><a name="rest_code_a34dbbe949e04b83b778e7d599622eae-1"></a><span class="gp">$</span> nikola plugin --uninstall tags
- <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-2"></a><span class="go">[2014-04-15T08:59:24Z] WARNING: plugin: About to uninstall plugin: tags</span>
- <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>
- <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-4"></a><span class="go">Are you sure? [y/n] y</span>
- <a name="rest_code_a34dbbe949e04b83b778e7d599622eae-5"></a><span class="go">[2014-04-15T08:59:26Z] WARNING: plugin: Removing /home/ralsina/foo/plugins/tags</span>
- </pre><p>And upgrade them:</p>
- <pre class="code console"><a name="rest_code_24342a29a808464f92514eb66426302c-1"></a><span class="gp">$</span> nikola plugin --upgrade
- <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>
- <a name="rest_code_24342a29a808464f92514eb66426302c-3"></a><span class="go">Will upgrade 1 plugins: graphviz</span>
- <a name="rest_code_24342a29a808464f92514eb66426302c-4"></a><span class="go">Upgrading graphviz</span>
- <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>
- <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>
- <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>
- <a name="rest_code_24342a29a808464f92514eb66426302c-8"></a><span class="go">Contents of the requirements-nonpy.txt file:</span>
- <a name="rest_code_24342a29a808464f92514eb66426302c-9"></a>
- <a name="rest_code_24342a29a808464f92514eb66426302c-10"></a><span class="go"> Graphviz</span>
- <a name="rest_code_24342a29a808464f92514eb66426302c-11"></a><span class="go"> https://www.graphviz.org/</span>
- <a name="rest_code_24342a29a808464f92514eb66426302c-12"></a>
- <a name="rest_code_24342a29a808464f92514eb66426302c-13"></a><span class="go">You have to install those yourself or through a package manager.</span>
- </pre><p>You can also share plugins you created with the community! Visit the
- <a class="reference external" href="https://github.com/getnikola/plugins">GitHub repository</a> to find out more.</p>
- <p>You can use the plugins in this repository without installing them into your
- site, by cloning the repository and adding the path of the plugins directory to
- the <code class="docutils literal">EXTRA_PLUGINS_DIRS</code> list in your configuration.</p>
- </section>
- <section id="advanced-features">
- <h1><a class="toc-backref" href="#toc-entry-94" role="doc-backlink">Advanced Features</a></h1>
- <section id="debugging">
- <h2><a class="toc-backref" href="#toc-entry-95" role="doc-backlink">Debugging</a></h2>
- <p>For pdb debugging in Nikola, you should use <code class="docutils literal">doit.tools.set_trace()</code> instead
- of the usual pdb call. By default, doit (and thus Nikola) redirects stdout and
- stderr. Thus, you must use the different call. (Alternatively, you could run
- with <code class="docutils literal">nikola build <span class="pre">-v</span> 2</code>, which disables the redirections.)</p>
- <p>To show more logging messages, as well as full tracebacks, you need to set an
- environment variable: <code class="docutils literal">NIKOLA_DEBUG=1</code>. If you want to only see tracebacks,
- set <code class="docutils literal">NIKOLA_SHOW_TRACEBACKS=1</code>.</p>
- </section>
- <section id="shell-tab-completion">
- <h2><a class="toc-backref" href="#toc-entry-96" role="doc-backlink">Shell Tab Completion</a></h2>
- <p>Since Nikola is a command line tool, and this is the 21st century, it's handy to have smart tab-completion
- so that you don't have to type the full commands.</p>
- <p>To enable this, you can use the <code class="docutils literal">nikola tabcompletion</code> command like this,
- depending on your shell:</p>
- <pre class="code console"><a name="rest_code_11b92258c62841bb95f453aef9a976b4-1"></a><span class="gp">$</span> nikola tabcompletion --shell bash --hardcode-tasks > _nikola_bash
- <a name="rest_code_11b92258c62841bb95f453aef9a976b4-2"></a><span class="gp">$</span> nikola tabcompletion --shell zsh --hardcode-tasks > _nikola_zsh
- </pre><p>The <code class="docutils literal"><span class="pre">--hardcode-tasks</span></code> adds tasks to the completion and may need updating periodically.</p>
- <p>Please refer to your shell’s documentation for help on how to use those files.</p>
- </section>
- </section>
- <section id="license">
- <h1><a class="toc-backref" href="#toc-entry-97" role="doc-backlink">License</a></h1>
- <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
- components shipped along with Nikola, or required by it are released under
- other licenses.</p>
- <p>If you are not familiar with free software licensing, here is a brief
- explanation (this is NOT legal advice): In general, you can do pretty much
- anything you want — including modifying Nikola, using and redistributing the
- original version or the your modified version. However, if you redistribute
- Nikola to someone else, either a modified version or the original version, the
- full copyright notice and license text must be included in your distribution.
- Nikola is provided “as is”, and the Nikola contributors are not liable for any
- damage caused by the software. Read the <a class="reference external" href="https://getnikola.com/license.html">full license text</a> for details.</p>
- </section>
|