Fail build if two posts resolve to the same permalink in Jekyll - jekyll

In my Jekyll site I have a permalink structure like this in _config.yml:
permalink: /blog/:title:output_ext
And I have two posts (in _posts) that resolve to the same permalink silently, for example:
2020-10-15-my-post.md
2020-10-16-my-post.md
Only one is written to _site/blog/my-post.html.
Is there a way to halt the building of the site, and throw an error, if two posts resolve to the same permalink (and then, one post overwriting the other)?

The Jekyll CLI has a command called doctor that outputs any deprecation or configuration issues with your site and, among other things, it detects when two posts resolve to the same permalink.
You can run it similarly to how you build your site today:
bundle exec jekyll doctor
In the example you gave in your question, jekyll doctor will show you an error message about a conflict between two pages, similar to this:
Configuration file: /your-website/_config.yml
Jekyll Feed: Generating feed for posts
Conflict: The URL '/your-website/_site/blog/my-post.html' is the destination
for the following pages: /your-website/_posts/2020-10-15-my-post.md,
/your-website/_posts/2020-10-16-my-post.md
When jekyll doctor finds a conflict like the above, its exit code will be non-zero which you can use to fail the build.

Related

How to use docson widget with Sphinx on ReadTheDocs

I'm working on the documentation (https://global-coffee-data-standard.readthedocs.io) of my JSON schema (https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/global-coffee-data-standard.schema.json)
The basics I have working (thanks to a lot of help from this forum) but now I would like to include the docson widget to show my code more beautiful (https://global-coffee-data-standard.readthedocs.io/en/latest/explanation.html#id13)
I've read this page https://threesixtygiving-standard.readthedocs.io/en/latest/_static/docson/README/ and I'm wondering how to install docson locally but more important on ReadTheDocs.
Do I need to run npm i docson localy? If so which files do I commit to my _static folder so ReadTheDocs can work with it as well?
Or can I put some magic in conf.py to let Sphinx handle it?
EDIT
I tried adding the docson files to my _static folder and it seems to work when I add this code to my ReST file:
<script src="_static/docson/js/widget.js" data-schema="https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/global-unique-id.json"></script>
But only when I add just one docson widget. When I add more I get this error in the console:
only one instance of babel-polyfill is allowed.
So I'm assuming this is not the correct workflow.
What is the correct workflow to add multiple docson widgets to my page.

Jekyll custom placeholders

I am trying to set up a jekyll site that sources its pages from github repository. I can "bring" that repository using the git submodule command so that works just fine.
The URL I want to have is:
https://example.ld/:version/:language/:page-name
For the :page-name I can use the :title global placeholder.
My folder structure is:
posts
posts/1.0
posts/1.0/en
posts/1.0/en/about.md
....
posts/1.0/fr
posts/1.0/fr/about.md
....
I tried playing around with the permalink option in the configuration but cannot find the right combination to do what I need since :language of course does not exist as a placeholder or does :version.
Is there a way to define those so that my users can visit the site and view https://example.ld/1.0/en/about?
Should I move the docs folder under the _posts folder?
Any pointers are more than appreciated. Thank you.

Mkdocs site is opened incorrectly

I've got mkdocs.yml file which looks like:
site_name: blabla
pages:
- One page: page2.md
- Second page: page2.md
- Navigation: Navigation.md
When I open it url is like this: http://10.2.0.8/blabla/master/Navigation.md and doesn't work and I get 404 Not Found
nginx/1.14.0 (Ubuntu) error. If I delete .md at the end of url it works fine.
However, on locally it opens like http://127.0.0.1:8000/Navigation/
does anyone know what's the problem with this?
As described in the official mkdocs documentation, the intended behavior is that http://10.2.0.8/blabla/master/Navigation.md does not exist, but rather http://10.2.0.8/blabla/master/Navigation as shortcut for http://10.2.0.8/blabla/master/Navigation/.
What might have gone wrong in your case is the deployment of the HTML & CSS files. Assuming that your markdown sources are in ~/blabla, a mkdocs build --clean within that directory will create a subdirectory ~/blabla/site/ which you then have to deploy in the respective directory, say /var/www/html/blabla/. Under Linux, I suggest a rsync -r --delete-before ~/blabla/site/* /var/www/html/blabbla/. In other words: The issue might also be that you simply have not deployed the whole site or at a different place.

Generate index pages showing posts for each date in Jekyll

This seems really basic and yet I've been searching for it and can't find anything. I'm working on converting an old legacy/proprietary blog I have into Jekyll. So far it's going well and I have most things working well. I've run into an issue with generating indexs per date.
I'd like to have something like the following:
http://example.org/2012/01/03
http://example.org/2012/02/02
etc...
Where each of those paths pulls up a listing of posts for that date. So on the Jekyll side, I'd guess I'd see something like:
_site/2012/01/03/index.html
_site/2012/02/02/index.html
etc...
...where I can specify a template for generating those listing pages. How do you go about doing this in Jekyll?
Turns out there was already a plugin for this solution:
https://github.com/jekyll/jekyll-archives/
I simply followed the documentation and creating a configuration like the following:
jekyll-archives:
enabled: ['day']
layout: 'archive'
permalinks:
day: '/:year/:month/:day/'

Jekyll variable site.static_files is null

I have an ultra simple Jekyll site that builds without error and Jekyll variables seem to be populated as expected except site.static_files which is null, despite there being a bunch of static files.
Here is a link to the source code. And here is a link to the output.
Edit:
Github pages uses Jekyll 1.5 and static_files are only available since version 2.0.0 (see history)
Edit #2 08-24-14
Github is currently at 2.2.0, so we can use site.static_files