.. vim: set expandtab fileencoding=utf-8 nomodified wrap textwidth=200 shiftwidth=2 ts=2 foldmethod=marker foldcolumn=4 ruler showcmd lcs=tab\:|- list: .. title: 2019-08-11 Nikola - making projects with shared resources .. slug: 2019-08-11-nikola-making-projects-with-shared-resources .. date: 2019-08-11 23:52:03 CEST .. tags: nikola .. category: SW .. link: .. description: How make easy links in nikola .. type: text .. author: Gilhad .. |logo| image:: /images/logo/gilhad.png |logo| 2019-08-11 Nikola - making projects with shared resources - or How make easy links in nikola .. TEASER_END `Problem with paths and shared files `_ is, that project had to be split to many directories (posts, listings, images, files, ...) and when some pages can have identical name accross projects (like index, example1, summary, etc. etc) each project had to occupy different subdirectory in post to avoid conflicts. So addressing all images, listings ... is complicated, as there must be every time repeated the path of the project and it is hard to auto-fill it when editing posts. I asked at forum, but there is not easy solution to it and also it does not seem to be common problem (maybe another static generator address it better, but it is hard to say and find all other possible problems there - so I tried to hack nikola somehow). My hack is, that each project directory (or even each post directory) will have symlinks like listings, images, etc. which would go to respective directories under /listings, /images ... where I will create subdir structure named blog (as all my post go to /blog subdir by conf.py) and in /files I will create the same structure and symlinks to respective output/listing/... etc. directories. Then I am able to use short names like images/logo.jpg and listings/example1.ino in my posts (and editor can complete those filenames), put all pictures and listings in this "directories" by symlinks, while in output they will end under the project directory with the same names thanks to symlinks in /files. Ofcourse there is a catch - *nikola build* would fail, as it makes the output files and directories in other order ((and maybe even random), than I would like. So sometimes the symlinks from /files are copied as symlink, sometimes like directories filled with the right files. The fix is easy - just delete all symlinks in /output (by *find output/ -type l -delete* ) and run *nikola build* again, this time successfully. Here is a script, which manages listings/ and images/ - it could be simply expanded to other directories/symlinks as well `listings/nikola_links.sh.html `_ and source in `listings/nikola_links.sh `_