The Stochastic Game

Ramblings of General Geekery

The Journey To Digital Comics: Manga Apps

In the previous step in the journey to digital comics we looked at american comics – my main source of graphical entertainment. This time, we’ll look at mangas and its derivatives (manhwa, etc.), which used to be my close second until I became too old to read about high-school girls, alien high-school girls, demon alien high-school girls, and miniature gender-swapping demon alien hunter high-school girls. But then I figured, fuck it, I’ll just look like a creepy old guy in the bus. No worries.

IMG_6354.jpg

A bit of history

Depending on how you look at it, digital mangas are either way beyond the american comics offer, or way behind. That’s because mangas and anime always had a vibrant “ethical piracy” scene, with scanlations and fansubbing. Most of the productions coming out from Japan or elsewhere in Asia historically, well…, never came out of there. It was impossible for fans anywhere else in the world to read those books or watch those TV shows. As a result, a community of translators, scanners and recorders was born.

That community was originally dedicated to supporting the original authors, however: whenever a specific series was licensed in the USA, the scanned manga or recorded TV series would be removed from the servers, and visitors would be gently redirected to the website of the company who licensed the product.

Of course, it didn’t take long for the community to branch up in several groups that would not necessarily follow that rule – whether it was because they catered to fans from other countries than the USA (there’s a lot of those) or to people who just want free shit (there’s even more of those).

Because of this pretty exhaustive free offer of digital mangas, the licensed and legal offer took a long time to materialize and, to this date, is still in its infancy.

As far as I know, the only available apps for legal digitial mangas on the iPad are Viz Media, Yen Press and Digital Manga Publishing (DMP). A couple more apps are available in the USA, like the Kodansha app, but not here in Canada – which shows how short-sighted some of those publishers are.

Some other publishers are at the bottom of the well. Square Enix, for instance, only offers to read your purchased book on your PC, as far as I can tell, and their website’s user interface is horrible – and I’m not the only one who thinks so. To give you an idea: it doesn’t even work in Google Chrome.

Worse, most of those previously mentioned apps are only available on iOS: only DMP’s app is available on Android. The other publishers’ books can sometimes be accessed via their website, but not always, which is bad. And when it is, it will mostly be Flash-based readers, which means that even on a good Android tablet your reading experience won’t always be optimal.

If that wasn’t enough, some publishers also handle purchases differently on the web and on the iPad, which means that the e-manga you bought may only be readable on one platform and not the other – this alone deserves a “worst idea ever” prize.

IMG_6359.jpg

You think it couldn’t get worse? Check this out: the Japanese Digital Comics Association is trying to reach out to its worldwide readers with an initiative called JManga. It’s a very nice idea: offer all their collective books through a unified web store… but if you go check it out, you will likely get a headeache – and also wonder if the website is legit because it looks like a spam/porn website run by Russian pirates. Also, as far as I can tell, there’s no iOS or Android app, which makes it useless (although some people are really dedicated to make it work).

IMG_6358.jpg

Overall, if you want a precise review of what apps are worth your time and money, you can read Manga Bookshelf’s “Going Digital” articles, like for example their “Manga on the iPad” wrap-up article from a couple months ago… but to be honest, I can’t find anything to be good enough at the moment.

The Viz Media app is the only promising one so far – it does what you expect, the interface is pleasant, the catalog is decent, and the prices are fair. The other apps, however, still suffer from various combinations of bad user experience, limited catalog, and digital mangas priced higher than their print counterpart.

Now given the little history lesson I gave in the introduction, you’re probably expecting a lot of apps offering scanlations on Android, and none on iOS (because Apple would be censoring them, right?) Well, not really. For some obscure reason, Apple approved several dozen apps and never looked back.

IMG_6353.jpg

Maybe it’s because they want a good offer in terms of digital comics to boost the iPad’s value proposition. Maybe it’s because they don’t know about scanlations. Maybe it’s because the legal status of those apps is more subtle than what you’d expect. Go figure. The only thing I know for sure is that the whole idea of iOS having better quality apps because Apple reviews every one getting on the AppStore didn’t really work in that case: a lot of those apps are shitty-looking, have horrible usability, or both. And I’m not even talking about the crashes.

All of those apps, however, have something in common: they all get their books from the same sources, namely MangaFox, Mangable and Mangareader. This means they all have similar catalogs, with similar quality, so the only differentiator is the user experience.

IMG_6352.jpg

As far as the iPad is concerned, the best app in that category was, hands down, the “MangaRock” collection of apps from Not A Basement Studio. It’s a bit confusing at first, because there are 3 apps, and it’s not obvious which one does what, so I’ll save you the trouble of finding out:

  • MangaRock and MangaRock MF are mostly designed for the iPhone, and only download books from, respectively, Mangable and MangaFox. They’re free, however, and have an iPad layout, so you can try those first.
  • MangaRock Unity is designed exclusively for the iPad. It’s not free, but it pulls books from all 3 previously mentioned scanlation websites simultaneously, and has a better suited UI. This means it has a better user experience overall.

Conclusion

At the moment, there is absolutely no incentive or advantage for you to read 100% legal digital mangas except for the warm and fuzzy feeling of being honest and spending your cash. If that’s you, then try the Viz Media app and its web counterpart – none of the other ones are worth your time and money for now.

For the other series not owned by Viz, I couldn’t recommend anything else than MangaRock Unity or, you know, the legal dead-tree real-world-space-taking book. The quality of the average scanlation is usually well below that of an official e-manga, and the translations are, at best, full of typos, but it’s good enough, especially if you just want to try something before buying the printed book.


Mercurial’s onsub and mixed sub-repos

If you’re using Mercurial with mixed sub-repositories (i.e. sub-repositories handled by different revision control systems), you may be interested in this: I just got a patch accepted into the onsub extension.

The extension lets you run commands on your sub-repositories. For example, with my own dotfiles repository, running on Windows:

> hg onsub "echo I'm in %HG_SUBPATH%"
I'm in libhghg-git
I'm in libhgonsub
I'm in vimbundlebadwolf
I'm in vim/bundle/colorschemes
I'm in vim/bundle/commentary
I'm in vim/bundle/ctrlp
I'm in vim/bundle/easymotion
I'm in vim/bundle/fugitive
I'm in vimbundlegundo
I'm in vim/bundle/haml
I'm in vimbundlelawrencium
I'm in vim/bundle/markdown
I'm in vim/bundle/nerdtree
I'm in vimbundlepiecrust
I'm in vim/bundle/powerline
I'm in vim/bundle/ragtag
I'm in vim/bundle/repeat
I'm in vim/bundle/solarized
I'm in vim/bundle/supertab
I'm in vim/bundle/surround
I'm in vim/bundle/syntastic
I'm in vim/bundle/vimroom

As you can see, I’ve got quite a few sub-repos. However, some are Mercurial sub-repos, while others are Git sub-repos (that’s one of the nice features of Mercurial: it has decent interop with other RCSes). Which ones are which, though? That’s easy, there’s a new HG_SUBTYPE environment variable now:

> hg onsub "echo I'm in [%HG_SUBTYPE%]%HG_SUBPATH%"
I'm in [hg]libhghg-git
I'm in [hg]libhgonsub
I'm in [hg]vimbundlebadwolf
I'm in [git]vim/bundle/colorschemes
I'm in [git]vim/bundle/commentary
I'm in [git]vim/bundle/ctrlp
I'm in [git]vim/bundle/easymotion
I'm in [git]vim/bundle/fugitive
I'm in [hg]vimbundlegundo
I'm in [git]vim/bundle/haml
I'm in [hg]vimbundlelawrencium
I'm in [git]vim/bundle/markdown
I'm in [git]vim/bundle/nerdtree
I'm in [hg]vimbundlepiecrust
I'm in [git]vim/bundle/powerline
I'm in [git]vim/bundle/ragtag
I'm in [git]vim/bundle/repeat
I'm in [git]vim/bundle/solarized
I'm in [git]vim/bundle/supertab
I'm in [git]vim/bundle/surround
I'm in [git]vim/bundle/syntastic
I'm in [git]vim/bundle/vimroom

That makes it possible to do something slightly different depending on the sub-repo type, but it’s still tedious. For example, the most common operation for me is to pull and update all those sub-repos. The commands are different (hg pull -u vs. git pull) and doing an if statement in Bash or Cmd is cumbersome, especially as a one-liner argument.

That’s where the other new feature comes in: there’s a new -t/--type option that filters sub-repos based on their type:

> hg onsub -t hg "echo Mercurial subrepo: %HG_SUBPATH%"
Mercurial subrepo: libhghg-git
Mercurial subrepo: libhgonsub
Mercurial subrepo: vimbundlebadwolf
Mercurial subrepo: vimbundlegundo
Mercurial subrepo: vimbundlelawrencium
Mercurial subrepo: vimbundlepiecrust

This makes it easy to bring all the sub-repos up to date:

> hg onsub -t hg "hg pull -u"
> hg onsub -t git "git pull"

Hopefully it makes life easier for a few other people out there… it sure does for me!


Graphicly: Continually Evolving For Content Publishers

Graphicly just announced a dramatic change of direction:

In challenging ourselves to think broader and wider, we stumbled on a very simple idea: the best place to sell books is in a bookstore. It’s an idea that’s worked for hundreds of years in the real world, so why not extend that to the digital world. Additionally, with close to a hundred million installs of Kindle, iBooks, Nook and others (and not to mention the close to a billion Facebook users) it makes complete sense to provide a platform for publishers and creators to take advantage of those native marketplaces.

They’re basically dropping out of the digital comics store race to focus on helping publishers digitize their content and delivering it on existing, well-established digital stores.

It means I did well not to buy any books on Graphicly and recommending to always go through a publisher’s official store. However, it sucks for people who did buy books on their app. The Graphicly app won’t be available for download anymore, and unless you still have it on your tablet or phone, you will have to read your comics on the web reader. Since it’s not uncommon for a smartphone or tablet to have a problem that forces a factory reset of some sort, or for a user to upgrade to a new portable device, it means those previously purchased comics are lost — who wants to read comics in a browser, and how long until Graphicly eventually unplugs all those servers that only lose money?

Although I wish the Graphicly guys all the best, it’s a harsh reminder that digital goods, for all the advantages they have on traditional goods, come with a lots of problems when they are locked into an ecosystem (whether it’s with DRM or just web-service obfuscation). I hope that we’ll see the same kind of revolution we’ve seen with digital music — but in the meantime, it reinforces my opinion that you should use whatever means necessary to get yourself a personal backup of anything you buy online.


Announcing PieCrust For Vim

After my Mercurial plugin for Vim, Lawrencium, here’s my second official Vim plugin! You won’t be surprised to know it’s a PieCrust plugin which adds a few commands that make it easier to work on your website. It’s of course named “vim-piecrust” and is available on BitBucket.

Old Time Tropical Pie

Well, actually, at the moment it’s only got on command: Pcedit. You will need the latest PieCrust to make it work. When you do, typing :Pcedit something<tab> in Vim will bring an autocomplete list that contains any page, post or template that contains “something” in its filename. It makes it very quick to edit files in your website.

I’ll add more commands in the future of course.


The Journey To Digital Comics: US Comics Apps

The first step in the journey to digital comics was to figure out what kind of hardware device to use. I concluded at the time that either the Transformer Prime or the iPad were the best choices available (the first one for its ideal aspect ratio and superior resolution, and the second one for its better use as a general tablet device). Since then, the New iPad (or iPad 3 if you read this 2 years in the future… thank you Apple) was released with a new fantastic display that makes it the best reading tablet on the market, so you may want to look into this one as well.

IMG_6095.jpg

The second step is to find out what channels are available to get your american comics fix.

The Elephant in the Room

Before we get to the real stuff, let me rant a bit on the subject everyone knows about: piracy. Like any other media, comic books are pretty easy to find on torrent websites or newsgroups, and it’s handy to download that stuff for free. You can then use an app like FileBrowser or even Dropbox to get the
files on your tablet, and use any of the pretty decent comicbook viewers, like Bookman, to read them.

But where I really don’t care one way or the other when it comes to movies and TV, the comics medium is much more special to me and I refuse to go through illegal means. First, pretty much none of the comics authors are nearly as wealthy as a movie actor or director – at least not the kind of actor or director whose movies you would steal. Second, it’s not like the comic industry has ever been doing well. Third, I just really want to give my money to those guys. I even purposedly avoid buying comics through iOS’s in-app purchases to make sure as much of my money as possible goes to the authors (skipping Apple’s 30% tax).

The Big Ones

Comixology

IMG_6104.jpg

When it comes to american comics, the one app that’s slowly taking over the whole market is Comixology’s Comics app, available on iOS, Android and Kindle Fire at the time of this writing. You can also read comics in any Flash-friendly browser.

It’s got a very decent catalog, and it’s constantly expanding with back issues. A few indie publishers have deals with them, along with the big ones, including DC, Marvel and Image. DC even uses Comixology as their official digital store.

One of the cool things is that those publishers came to their senses relatively quickly and now offer “same day digital” books, where new issues are available in digital format at the same time they are available in your friendly neighbourhood comic store.

Prices for new issues are between $2 and $4 (which ranges from “Ok” to “Kinda expensive”), but those prices fall down to $1 to $3 for older issues. They also have very frequent sales – not all of which would be of interest to you, of course, but it’s still a welcome policy.

Dark Horse

IMG_6102.jpg

Dark Horse decided to not go the Comixology way like the other big guys. It could have been a disaster – sometimes if you want something done right, it’s best not to do it yourself, especially if that’s not your core business – but it turned out ok.

Their online store is decent, and has a nice feature where you can search directly for “bundles” (the rough equivalent of a TPB). Prices are similar to those on Comixology, and the catalog seems well furnished (at least they have all the series I follow). As far as I can tell, they also got on board with the “same day digital” idea, which is good.

Their apps (iOS and Android at the moment) get the job done, but are not as smooth as Comixology’s. For example, you can’t start reading a comic while it’s downloading, and the navigation is sometimes a bit weird.

Graphicly

IMG_6103.jpg

I really wanted Graphicly to succeed in the market: it’s obviously run by people who love comics, and they advocate open, standardized formats that put the reader in control. But this kind of philosophy is a sure way to alienate publishers, and it’s a miracle to me that they still got, among others, Marvel or Image on board somehow, even if it’s only for a small percentage of their catalog (Marvel currently has 125 series on Graphicly and Image 111, compared to respectively 525 and 336 on Comixology).

So even though you could buy some mainstream comics on Graphicly, I’d have a hard time recommending it – you would have to split your collection between there and over at Comixology eventually, and, as we’ll see shortly, it’s better to not go through intermediaries.

Still, Graphicly has some value because they have the biggest indie comics catalog.

edit 2012/05/04: Graphicly stopped being a digital store.

The Fine Print

At this point, you would think everything’s wonderful: those apps are way more convenient than piracy, comics are available as soon as possible and everywhere (as far as I can tell – I’m in Canada), the prices are a bit high but not outrageous, you can read your books on a lot of different devices, and most of the stuff you want to buy is available to begin with (something that would seem like “yeah, duh”, but is still not obvious to the movie and TV people)… they even get a few more things right, like giving away for free the first issue of many critically acclaimed series. But it’s not all roses, sadly.

First, you don’t really own your books – they’re more licensed to you than anything else. They’re stored in a somewhat obfuscated manner on your device, or in your web-browser’s cache, and that means you can never get to the files in case you want a personal backup, or just want to read them in a different comic reader whose interface you prefer. Not that this was ever a real problem so far, but it sure is bugging me.

Second, because we’re dealing with cloud storage, usual questions like “what happens to my purchases if Comixology or Graphicly goes bankrupt?” will pop up in your head every now and then. My only solution to that problem is to cut the middle man and, as much as possible, buy your comics from the source. This means buying Marvel comics from their own digital store, DC comics from Comixology (which is their official digital store) and so on. Sadly, it means pushing guys like Graphicly out of the game (except for indie comics), but at least your money and purchase records are stored with the guys you really got your stuff from, and that’s your best chance of not getting screwed in a few years.

Third, whatever app you choose to buy a comic through will be the app you need to read it with – as if you had to use a different music player depending on where you bought a song. It’s another non-problem – as long as all readers have a decent interface and rendering engine – but it’s also slightly annoying.

The Marvel Problem

added 2012/03/30

It should be noted that Marvel is its own little world of problems at the moment. Early on, their digital strategy was quite confusing. Some of those problems disappeared – I can’t seem to find comics priced differently across apps anymore – but some remain:

  1. As far as I know, Marvel is the only publisher that uses Comixology software with their own database. Both DC and IDW apps are Comixology based, and comics bought through their store are also available in the main Comixology app (and vice versa). Not so much with Marvel, where the 2 apps are completely separate.
  2. The Marvel Unlimited Subscription sounds like a good deal: for a flat monthly fee you can read as many comics as you want. You may not get the full Marvel catalog or all the new hot releases, but it’s very interesting if you want to read all the famous golden and silver age story arcs from a few decades ago. The problem is that the Marvel Unlimited Subscription is not available on mobile devices. Yes, you read that right: the only sensible way to read a digital comic is not acceptable when it comes to reading a shitload of comics. And Marvel will not quite tell you in a straight way: instead they just mention, in small print, that it “requires Flash & internet-connected PC or Mac”. You have to guess that this excludes tablets and phones… or you do like me: get the subscription, realize after 30 seconds that it doesn’t work in their own fucking app, and ask for a refund. Marvel, you are fucked up.

Conclusion

A summary of all of the above is that I read my Marvel comics on the Marvel app, my Dark Horse comics on the Dark Horse app, and everything else on Comixology. And when I need to buy something, I avoid the in-app purchases and Apple’s 30% tax, and go instead to the app’s web store in Safari.

In the next step we’ll deal with reading digital mangas, and then move on to the pros and cons and whether digital comics are right for you.


Who Buys Books?

Tim Bray on buying books:

This works because Amazon doesn’t mind multiple devices at once having access to a book; and because our “Amazon identity” is a lightweight shopping-context thing, not like a “This is really me” Facebook or G+ identity.

This highlights a very important thing about Internet identity: identity is not something that can be modeled easily, and it’s certainly not something that’s unique, whatever Mark Zuckerberg may think.

I use the same scheme as Tim when it comes to buying Kindle books – right now I only share with my wife but the kids will get on board when they’re old enough – and that’s OK because our Amazon account reflects the family unit as the customer: when you buy a book or a movie or, for that matter, a TV or a car, you don’t buy it as yourself but as a member of a group. Some companies may have thought otherwise all these years, but it’s always been the case.


Piecrust 0.6.0

I’ve been focusing a lot of my free time on PieCrust these days – to the point where my other projects are suffering from it – but I’m getting close to a possible 1.0 release, which is good! But in the meantime, here’s version 0.6.0, which is not very big but still has some goodness in it.

Rhubarb Apple Pie

You can go read the newly created CHANGELOG file for the whole list of changes, new features and bug fixes, but here are the most important ones, right after the break.

  • Twig and LessPHP have been updated to their latest version.
  • Added a chef prepare command to quickly create pages and posts files. For example, if you type chef prepare post my-new-whipped-cream-recipe, Chef will create a post file at the appropriate location (depending on your posts file-system setting) for the current date and time.
  • Added a wordcount Twig filter which does pretty much what the name says, although the count is likely to be off by a few words since the counting algorithm is extremely naive and is run before Markdown or Textile formatting. Still, I think it’s a good indicator of how long the article is – maybe I’ll revisit the algorithm if people express interest in a more accurate one (although it could quickly become complex if you consider internationalization).
  • Added a --nocache parameter to Chef if caching should be disabled for the current command.
  • Chef’s --debug parameter used to also kinda change how PieCrust is running. Not anymore: it’s now just changing the verbosity of Chef, just like --quiet.

Big thanks to the people who reported bugs and helped me fix them.


Showing off your dotfiles

With the introduction of my first Apple laptop a few years ago, my home computers went from being half Unix-like (I had a healthy mix of Linux and Windows machines) to mainly (two thirds) Unix-like. With it came a change in the kind of software I use on a daily basis and an increased need to synchronize the configuration of those programs between my machines.

Enter the “dotfiles community”: an informal group of people who, as Zach Holman puts it, think that “dotfiles are meant to be forked”.

“Dotfiles” are rooted in Unix culture – the name refers to the configuration files starting with a dot that clutter your home directory like crazy. This means you will mostly find Mac and Linux users in there (that’s ok, they’re pretty nice… usually), but to me it’s mostly about putting all your configuration files in source control in a way that makes it easy to setup new machines and share with others.

Show-off :-)

So like everybody else, I put my dotfiles out there for anyone to poke around. They’re mostly boring, but you may find a few useful things, like those I outline below (after the break). Nothing earth-shattering, but if it saves you the 15 minutes needed to write it, that’s 15 minutes you can spend on doing actual stuff.

Boostraping

Most people store their dotfiles in a Git or Mercurial repository, and then create symlinks from their home directory into the repo (like, for instance, linking $HOME/.vimrc into $HOME/DotFiles/vim/.vimrc). Because I also need some of those configuration files on Windows, I can’t really hard-code paths like this.

As a result, I opted for generating some of my dotfiles when I run my install script. Those dotfiles mostly only include the real ones from the repo. This lets me clone my dotfiles repo anywhere I want – no need to hard-code anything.

Mercurial config includes

An often overlooked feature of Mercurial’s config files is the %include statement which lets you include other config files. This lets me specify OS-specific config files to my hgrc, and even optionally have a local config file (since the %include statement will quietly fail if the included file doesn’t exist).

Cross-platform, multi-language Vim

If you’re running Vim on both MacOS and Windows, you may be interested in a few lines from my .vimrc, like when it figures out the directory for all the Vim runtime files (.vim on MacOS, vimfiles on Windows).

You may also be interested in a couple of international features I have:

  • A mapping to switch keyboard layouts in input mode (I switch between English and French)
  • A mapping to switch spell-checking on and off, and the language it will be checking against is in sync with the input mode keyboard layout.

That’s it! I hope somebody finds it helpful in some way.


Lawrencium — A Mercurial Wrapper For Vim

I’ve been using Vim for quite a while now, and by no means am I an expert in it (I’m still learning all kinds of cool tricks every week), but I recently decided it was time to write my first plugin. And because I mostly use Vim at home, where I work with Mercurial, I figured I could write a Mercurial plugin for Vim.

vim

Steve Losh had been asking for such a plugin for quite some time so I thought that might be helpful to at least another guy besides me. And ironically enough, I started learning Vimscript with Steve’s very own book-in-progress, “Learn Vimscript the hard way”.

The result of this initiative is Lawrencium, which is available on Bitbucket and at Vim.org.

There’s a good description of how it works on the Bitbucket page, and you’ll see it’s inspired in some parts by Tim Pope’s Fugitive plugin, which wraps Git workflows and features inside Vim.

It’s still a work in progress so be sure to leave some feedback here or in the issue tracker.


Navigation menu in PieCrust

Here’s another post in the PieCrust cookbook series, this time focusing on a classic web-design pattern: the navigation menu.

Menu

It’s really just a bunch of links that you can put somewhere around each page’s content, but the trick here is to tell the user which page he’s currently on. This is pretty easy to do using Twig macros and the data exposed by PieCrust, assuming of course you’re using PieCrust’s default template engine.

Let’s start by building a simple layout. I skipped the parts that are not relevant:

    <!doctype html>
    <html>
    <body>
        <div id="content">
            {{ content|raw }}
        </div>
        <div id="navigation">
            <ul>
                <li><a href="{{ pcurl('') }}">Home</a></li>
                <li><a href="{{ pcurl('something/foo') }}">Foo!</a></li>
                <li><a href="{{ pcurl('about') }}">About</a></li>
                <li><a href="{{ pcurl('contact') }}">Contact</a></li>
            </ul>
        </div>
    </body>
    </html>

This is a pretty standard PieCrust layout, but we want the user to know which one of those 4 navigation links is the current page. Here’s a way to do it.

Step 1: Write the macro

You can write a macro that, depending on the current page’s “slug” (the page’s URL name1), prints either a link or just some text with the active class.

{% macro nav_entry(slug, current, label) %}
{% spaceless %}
{% if current == slug %}
<span class="active">{{ label }}</span>
{% else %}
<a href="{{ pcurl(slug) }}">{{ label }}</a>
{% endif %}
{% endspaceless %}
{% endmacro %}

Note the use of the spaceless tag to make sure we don’t have ugly carriage returns and spaces in our resulting markup (we want everything on one line). This is not required – it just makes the HTML prettier.

Step 2: Import the macro in the layout

You can either put the above macro in a separate file (say, _content/templates/nav_macros.html), or at the beginning of your layout file – it depends on whether you want to reuse those macros elsewhere, and whether you want to keep your layout markup cleaner.

If you put the macro in a separate file, you’ll need to import it in your layout file with Twig’s import tag:

{% import "nav_macros.html" as nav %}

Here, we imported in the nav namespace, so you can call your macro with nav.nav_entry.

If you put the macro right there in the layout file, you have to prefix the calls with _self like so: _self.nav_entry.

For more information, see the Twig documentation on macros.

Now you can replace the navigation links with calls to the macro:

    <div id="navigation">
        <ul>
            <li>{{ nav.nav_entry('', page.slug, 'Home') }}</li>
            <li>{{ nav.nav_entry('something/foo', page.slug, 'Foo!') }}</li>
            <li>{{ nav.nav_entry('about', page.slug, 'About') }}</li>
            <li>{{ nav.nav_entry('contact', page.slug, 'Contact') }}</li>
        </ul>
    </div>

Unfortunately, you need to pass page.slug to the macro every time because the macro doesn’t have access to the current context as far as I can tell.

Add a bunch of CSS styles that will handle the active class and voilà, you’ve got a nice navigation menu.

I’ve slapped together a little demo website here so you can see it in action.


  1. Strictly speaking, PieCrust’s definition of “slug” is not quite correct since it includes the root-relative folders that contain the resource, but… well… whatever. ↩︎