Thank you, I will play a bit with proposal 1) and see if I can mange a workable solution.
Meanwhile I'll stick with an extra dev template file, import it in base.tmpl and comment it out by hand before deploy. [email protected] schrieb am Donnerstag, 29. September 2022 um 22:11:10 UTC+2: > On Wed, 28 Sept 2022 at 11:08, 'Dirk Olbrich' via nikola-discuss > <[email protected]> wrote: > > > > Hey there, is there a way to detect if Nikola is running in `auto` or > `serve` mode and use this variable in template files? > > > > I would like to build some templates which aid in development and only > show if I view the Nikola site locally via `nikola auto -b` or `nikola > serve -b`. > > > > Example: the [Hugo](gohugo.io) static site generator sets a variable > `Environment=development` during local builds with `hugo serve -w`. With > the variable `{{ if .Site.IsServer }}` within a template I can detect if > the site is running locally in server mode and decide which elements of > this template are rendered within the build site. > > Hi, > > this is not supported and won't be, because it breaks incremental > rebuilds. `nikola serve` is a fairly simple thing that just serves the > output directory. `nikola auto` runs `nikola build`, which affects the > contents of the output directory. > > There are two ways you could approach this: > > (1) on-the-fly HTML patching - this is something done by both commands > to remove <base> tags and inject livereload.js in auto, you could have > a custom serve command to do this. > (2) an alternate configuration file for use with `nikola auto` - but > if you forget to `nikola build` after achieving a satisfactory result > with `nikola auto`, you would either deploy the dev-only templates to > production (if you use the same output directory as in your main > conf.py), or deploy a stale version of the site (if you use different > output directories). > > -- > Chris Warrick <https://chriswarrick.com/> > PGP: 5EAAEA16 > -- You received this message because you are subscribed to the Google Groups "nikola-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/28bbaba6-7da3-4256-b504-cf2e97e5f365n%40googlegroups.com.
