How do I setup the Date URLs Plugin for DocPad? - docpad

I've recently converted from Octopress to Docpad and couldn't be happier. I like everything, but one thing bothers me. At the moment all paths on my site are built directly from the filename, e.g. www.site.com/posts/yyyy-mm-dd-title/. What I want to get is www.site.com/posts/yyyy/title. I found the Date URLs plugin, but cannot understand how to set it up. I tried inserting the relevant part into docpad.coffee as follows:
docpadConfig =
plugins:
dateurls:
cleanurl: true
trailingSlashes: true
collectionName: 'posts'
dateFormat: '/YYYY'
templateData:
site:
But nothing seems to change. The collection is defined as follows:
posts: ->
#getCollection("html").findAllLive({relativeOutDirPath:'blog'},[date:-1]).on "add", (model) ->
model.setMetaDefaults({layout:"post"})
--
EDIT (in response to Lukasz Gornicki)
A sample of metadata from the blog folder:
---
title: "Les Sapeurs"
date: 2014-09-25 07:39
comments: false
language: english
tags: video
keywords: anton zujev, antzoo, zujev, sapeurs, style, congo
description: Les Sapeurs are fashionistas from Congo, whose style is a political and social outcry.
---
A sample of metadata from the cast folder:
---
title: "Utan 7"
date: 2015-02-27 06:52
podfeed: utan
comments: true
---
I didn't try the debug mode before. Now I did, but I don't see anything special in the log. Here's the log file.

I've installed the plugin on my blog to check it out. I think there is a bug in documentation or it is just supper misleading. Documentation doesn't explicitly say that the url is build against the date metadata with dateFormat configuration and file basename without the date. I copied your configuration use it agains my blog with post 2015-02-16-test-test.html.md with metadata: date: 2014-09-25 9:49.
result url: http://localhost:9778/2014/test-test/
So the plugin works. Do you think that docpad doesn't pick up any configuration for the plugin? If you are configuring docpad with docpad.coffee I suggest you to validate the file, if it is created according to coffeescript rules and you have right indentation. Some time ago I had a situation that my config file grew a lot and some of the config was not picked up because of indentation.
Or just give access to the project so I can see and tell you what is wrong.
MORE DETAILS TO THE ANSWER AFTER CHECKING THE PROJECT:
Filename can have a date. The plugin uses regex to take just the string out of the filename - basename.
Locally I've commented out your hook into the renderBefore event, installed the plugin, added your config and all works as expected if it comes to the urls. So I get a URL like /2014/movie-quotes/
On the other hand it works when the server is started, but when I look on the out dir and try to generate the static content, it looks like the plugin doesn't work. Is this what you mean when saying that plugin doesn't work?

Related

Minima theme build shows "Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences"

Here's a link to my website Facey's Thoughts and here's a link to the GitHub Pages project.
Cloning the (working) repository to my local machine and trying to run jekyll build fails with this error:
Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences: social-icons/.svg Valid syntax: {% include file.ext param='value' param2='value' %} in assets/minima-social-ico.html
The Jekyll version is still the same as what's specified in my Gemfile:
jekyll 4.3.1. I have no idea what's changed.
I've tried removing the minima-social-ico.svg file; I've tried removing the posts that I was trying to add; I've tried searching Online for something similar to this issue without luck.
I tried jekyll build with local files, cloning my GitHub pages repo to a new directory, and that repo for sure built last night, and I've tried removing any new .markdown files that I made since the last time it successfully built.
I tried the following:
If I comment out social_links from my _config.yml file, it will build, I assume because it's not using the minima_social_icons.svg file. Why did it work and now it doesn't?
The problem is more with using the remote theme without locking to a specific commit/tag. (Since the v3.0 is still in development, any breaking change added to the main branch will break the build as well, if we refer to the latest changes always.)
One can lock to a specific commit/tag as: (in _config.yml file)
remote_theme: jekyll/minima#<insert-commit-hash_or_tag>
This time the breaking change was #686. Using social links more explicitly, as mentioned by Yshmarov should resolve the issue.
minima:
social_links:
- { platform: github, user_url: "https://github.com/jekyll/jekyll" }
- { platform: twitter, user_url: "https://twitter.com/jekyllrb" }
Updating social links to be more explicit solved it for me:
social_links:
- { platform: rss, user_url: "/feed.xml" }
- { platform: github, user_url: "https://github.com/yshmarov/" }
- { platform: twitter, user_url: "https://twitter.com/yarotheslav" }
- { platform: linkedin, user_url: "https://www.linkedin.com/in/yshmarov/" }

Github pages Jekyll static blog outdated

I setup a Jekyll blog on Github-Pages 5 months ago. It was working at that time, and I though it would be a nice place to post things.
Long story short, I wrote a first post, but then I never used, until yesterday when I wanted to check that all was working fine, but it was not. I also could not run Jekyll locally.
I do not use ruby on my daily basis ,so they were outdated. I though maybe if I update it and generate the site again everything is going to be working fine.
I updated ruby from 2.1.2 to 2.2.1, and I tried other things to make it work. Now is working locally, but throwing this
Generating...
Defaults: An invalid front-matter default set was found:
[{"scope"=>{"path"=>"_posts/"}, "values"=>{"author"=>"Agustin Gambina"}}]
Defaults: An invalid front-matter default set was found:
[{"scope"=>{"path"=>"_posts/"}, "values"=>{"author"=>"Agustin Gambina"}}]
I also added a Gemfile to the root directory
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
When I run
github-pages health-check
I get this
Checking domain littlebit.me...
Uh oh. Looks like something's fishy: Domain does not resolve to the GitHub Pages server
Does anyone know why it happened to me that is not working anymore? was because it was outdated and something changed?
thank you
You have an error in your _config.yml file :
-
-
scope:
path: "_posts/scala"
values:
author: Agustin Gambina
Must be :
-
scope:
path: "_posts/scala"
values:
author: Agustin Gambina
This is not a fatal error, so your site build, but your rule is not applied.
Concerning the health-check, it works for me as it checks littlebit.me that resolve to github IPs.
$: dig littlebit.me
...
littlebit.me. 1800 IN A 192.30.252.154
littlebit.me. 1800 IN A 192.30.252.153
If it doesn't work on your PC, you may have a DNS problem. Maybe you've set a bad value in your hosts file ?

Setting multiple categories in jekyll

I have a markdown file as follows:
---
title: My Page
categories:
- first
- second
---
In my _config.yml file, I set the permalink to /:categories/:title.html
So when I generate the site, the permalink ends up being /first/second/title.html, whereas
I was hoping Jekyll would create /first/title.html and /second/title.html
Is there a way to do this without custom plugins?
Cheers
The easiest and to me best way is to define the permalink via frontmatter. This is also great for search engine optimization. First you tell Jekyll via _config.yml how Jekyll should build the links if you forget to set it via frontmatter:
_config.yml
# Build settings
permalink: /:categories/:title/
Define a permalink...
2014-10-17_my_post.md
---
layout: post
title: 'Post with permalink'
permalink: /this-is-the-unique-permalink/
---
My Post
According to these docs, it looks like each Jekyll page can only have one category. categories is kind of a misnomer, because you're really defining a "category hierarchy" - like a file path - so the post really resides in a single (sub)category. In this limited sense, you can't do what you want with vanilla Jekyll.
However, Jekyll will process files just sitting around in any directory that doesn't start with an underscore and it follows symlinks. So, for example, if you make directories for each category and place your page in one of them, you can create symlinks to any number of other "categories".
mkdir first second
touch first/page.md
ln -s ../first/page.md second/

Generated markdown file with rake post command

I am deploying my github blog using jekyll-bootstrap.I try to modify Rakefile to change the result of $rake post title="test" and then this command will generate a file named test.md(without date) in _posts directory,but unfortunately,when I run
$jekyll serve
locally,it seems that jekyll do not think test.md is an available post,what shoul I do?
I think that what you want it's custom url for your posts.
Leave alone the rake task, because the final post filename is generated in accordance with a permalinks pattern see permalinks documentation
By default you posts are generated following the default pattern /:categories/:year/:month/:day/:title/index.html
If you want to change this pattern, in your _config.yml, use permalink key :
permalink: /blog/:year/:month/:day/:title/filename.html

symfony2 assetics yui compressor on windows (path syntax)

I'm trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don't work. When removing all filters from config.yml and the twig template, it works and php app/console assetic:dump does copy the css and js files.
Now I want to add the yui compressor and my config.yml looks like this:
assetic:
debug: %kernel.debug%
use_controller: false
filters:
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar
Adding the filter to the template and running assetic:dump again ends in the following error (translation of message by me):
[RuntimeException]
The syntax for filename, directory name or drive name is wrong
I found an article telling me to specify the path to java.exe, so I add this to config.yml:
assetic:
..
java: C:/Program Files (x86)/Java/jre6/bin/java.exe
..
Now assetic:dump tells me:
[RuntimeException]
The COMMAND "C:/Program" is either written wrong or
I tried playing around with both variables (using \ or \ instead of /, adding single or double quotes, working with short alias Progra~1 or Progra~2) in the config, but I didn't get anywhere. The both errors comming up all the time. Maybe someone can point me in the right direction.
Ok, I figured it out. Man, this one was brutal.
Let's start with the easy stuff. A working version of the config.yml can look like this:
assetic:
debug: false
use_controller: false
java: C:\Program Files (x86)\Java\jre6\bin\java.exe
sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
filters:
scss: ~
yui_js:
jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar
For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.
And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.
The Assetic\Util\ProcessBuilder has to be changed on line 95
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
,line 103
$script .= ' '.implode(' ', array_map('escapeshellarg', $args));
and line 110
return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);
I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.
Answer by Boo Nov 19 at 22:53 did work for me by changing everything he mentioned in Assetic\Util\ProcessBuilder (I ignored line 95 as it looks the same as in my file)
Now it works on windows. Thanks!
Just to confirm. Im using Symfony 2.0.7 and yuicompressor-2.4.7
For other users who use window server 2008 r2 :
Maybe you should change the C:\windows\Temp folder property to 777 (read/write) for the IIS user / or the machine's normal user
please unpack the ruby.7z from rubyinstaller.org , and go to C:\_ruby193\bin , in this unpack position you should exec the CMD prompt , type :
ruby -S gem install sass
so that you will get the sass.bat in that position
It's time to use Boo's best answer , and please notice that in symfony2 dev env maybe it's not necessary to change the use_controller to false (in the config.yml) , because there's another use_controller in the config_dev.yml (set to true) , and in routing_dev.yml there's also a _assetic router , they're perhaps associated.

Resources