[HOWTO] Create powerful specific templates for posts types and categories

Typo 6.0.6 introduced custom post types, allowing you to chose which template you want to use for your posts. Since Typo 6.0.8, you can also define per category templates.

Let’s say you blog about tech and wine, and want to display wine posts differently. You upload an attached picture to every wine related post and want it to be displayed in every article. You also have a custom CSS for wine blocks, and don’t want people to comment your wine reviews (this to make the sample template more readable). You also want to apply this to the category page.

I. Prepare the path

First, login to your blog admin and go to Article -> Post Types. Create a new post type called Wine.

Custom field 2

See the template name? Remember it, because we’re going to use it somewhere soon.

Custom field 2

Now, create a new category in Articles -> Categories. We’ll call it Wine too.

Custom template creation

Note the permalink id somewhere because we’re going to reuse it very soon.

Custom template creation

II. Create the templates you need

You’re going to create 2 custom templates: one to display wine related articles, and one to display the Wine category.

First, create a templates called wine.html.erb in your theme/views/articles/ directory. If the views/articles directory doesn’t exist, create it. The template will probably look like something like this:

<div class="wine">
  <h2><%= link_to_permalink @article, @article.title %></h2>
  <p class="auth"><%= _("Posted by")%> <%= author_link(@article) %>
  <%= display_date_and_time @article.published_at %></p>
  <%= @article.html(:body) %>
  <!-- This display the attached images -->
  <% @article.resources.each do |upload| %>
    <img src='<%= "#{this_blog.base_url}/files/#{upload.filename}" %>' class="centered" />
  <% end %>
  <div class="extended">
    <%= @article.html(:extended) %>

<p class="meta">
  <%= article_links @article %>

You’re now going to do the same with the wine category. In your theme /views/categories, create a wine.html.erb template. This is adapted from the category/show.html.erb of one of the stock themes.

<h1><%= link_to "Wine", "#{this_blog.base_url}/category/#{params[:id]}" %></h1>

<div class='category-excerpt <%= "border" if @article_counter >= 0 %>' id="article-<%= article.id %>">
<% @articles.each do |article| %>
  <h2><%= link_to_permalink(article, article.title) %></h2>
  <p class="auth"><%= _("Posted by")%> <%= author_link(earticle) %>
  <%= display_date_and_time article.published_at %></p>
  <%= article.html(:body) %>
  <!-- This display the attached images -->
  <% article.resources.each do |upload| %>
    <img src='<%= "#{this_blog.base_url}/files/#{upload.filename}" %>' class="centered" />
  <% end %>
  <div class="extended">
    <%= article.html(:extended) %>
<% end %>

<div id='paginate'>
  <%= will_paginate @articles, { :previous_label => _('Previous'), :next_label => _('Next')  } %>

Here you are, you can now write about wine. Just don’t forget to chose the wine post type within the editor.

Custom template creation

Published on 20/05/2016 at 08h26 by Matijs van Zuijlen, tags

Publify 8.2.0 – Rails 4.2

Publify master has been running on Rails 4.2 for some time, so a new release is long overdue.

Some important changes:

  • Dependency on Rails has been updated to 4.2, including recent security fixes.
  • Migrations have been rolled up to 113 according to our upgrade policy. You must now first upgrade to at least version 7 before upgrading to the latest version.
  • The default bootstrap theme was replaced with bootstrap-2. You can find the old theme at in its own repository.
  • A Plain theme was added that uses only Publify’s default templates with a sprinkle of custom css.

In addition, there have been numerous smaller changes, bug fixes and improvements. See the change log for details.

Published on 16/03/2016 at 15h39 by Matijs van Zuijlen, tags

Publify 8.1.1 – Rails 4 bug fix

Short after pushing 8.1.0, we’re releasing a quick bugfix one. We’re obviously too serious about “release early, release often”.

#497 Publishing breaks before adding tags and publishing time.

#498 Pages and articles editor appears on 2 lines only

#499 Autosave is broken on PostgreSQL

Download Publify 8.1.1

Published on 17/09/2014 at 20h37 by Frédéric de Villamil, tags

Publify 8.1.0

That was fast! Only 3 days after Publify 8.0.2 went live, we’re pushing a new 8.1.0 version.

This version does one thing: it migrates Publify from Rails 3.2 to 4.1.

It does not seem a lot, but there was actually a tremendous work from Matijs and Thomas to make it possible.

You may not be aware of it, but Publify is as old as open source Rails itself, and not only did they make our old code work under the latest version of our favorite framework, but they also modernized huge parts of our code.

It’s now time for them to take some rest, and for us to pick up the feature we want to see in the next version. Stay tuned!

Download Publify 8.1.0

Published on 17/09/2014 at 16h22 by Frédéric de Villamil, tags

Release of Publify 8.0.2

Hello world,

We’re thrilled to announce the release of Publify 8.0.2. This is the last release before we migrate to Rails 4, and mostly a bug fix one. It fixes a denial of service security breach, so we highly recommend updating.

As usual, we want to thank our contributors. For this release, they are Alexander Markov, Benoit C. Sirois, Hans de Graaff, Soon Van, Tor Helland and Nicolas Bianco.


Très Acton has discovered a risk of denial of service by memory exhaustion in the way Publify comments user input are parsed.

Other squashed bugs

#423 , #474: When using the more tag, articles content is displayed twice.

#428 The editor save bar jumps up and down when typing with inconsistent behavior.

#429: The help messages can’t be hidden.

#431: Avatars in the dashboard last comments block are not inline with the comment.

#432: Dashboard inbound links widget is broken.

#433: The admin / content search does not bring anything back.

#442,#453: The content and page editor layout are not consistent.

#443: When creating a post, tags are shown in white on white.

#444: The articles date picker does not allow to change the time the article is published.

#445: Using the articles date picker results in a 500 error.

#447: Marking content as spam using the thumb icon results in a 500 error.

#454: Media library: the JS refactoring removed the lightbox.

#455, #473: Admin / sidebar: trying to remove a sidebar item does not work.

#456: Admin / sidebar: the help box should be in a blue block.

#475: Lots of unused assets to clear.

#482: Cancel links are not displayed correctly.

#488: File upload is broken.

Link caching issue (All cached links are the same basically).

Use a relative image path for blogs installed outside of the site root.

Archive page is not cached.

Feature and improvement

Improved Russian, Norwegian and French translations.

Upgraded to Rails 3.2.18.

Added support for a human.txt.

Published on 15/09/2014 at 09h26 by Frédéric de Villamil, tags

[ANN] Publify 8.0.1 has been released!

Hi everyone,

I’m happy to announce that Publify 8.0.1 has been released. This is a small bug fix release, but it fixes some very annoying ones.

  • issue 398: the user-style.css stylesheet is not loaded in the Bootstrap theme
  • issue 399: the note style is not applied.
  • issues 402, 410, 411: deployment crashes on Heroku (thank you @slainer68 for fixing that).
  • issue 412: the editor locally saves the content of the edited note, which means it reloads it when you edit another note, overwriting the legit content.

I’d like to thank you all, every contributor who helped with this release.

Download Publify 8.0.1.

Published on 04/04/2014 at 18h58 by Frédéric de Villamil, tags ,

Publify 8.0

It’s been 5 months since Publify 7.1, and considering the figures, Publify 8.0 is the biggest release we ever pushed in 9 years: 474 commits, 71 issues closed, 8 contributors, 567 files changed, 60,767 additions and 45,166 deletions.

But you probably don’t care about numbers that much, except if you’re wondering whether or not the project is till alive. TL; DR: it is.

The project itself has known one big change, moving from Fred’s personal Github account to a dedicated organization. We have been thinking about it for a while, and we believe it’s the best we could do for Publify.

Simpler, better, faster

Last summer, we started to rethink what we wanted Publify to be. At a time where online publishing is more or less split between Wordpress, hosted platforms and static engines, being “only” a blogging platform had no meaning anymore. We started to extend publishing capabilities, choosing Twitter pushed short notes as a first step before we add more content type. This led to Publify 7.0, and once again we knew it was the way to go.

Before adding these feature, we wanted Publify 8.0 to rebuild the whole user experience. It had to be simpler, clearer and better, far from the MS Word 97 style that prevails in Web publishing since more than 10 years.

This meant a simpler interface with a single, smaller menu, getting out of the old create / read / update / delete scheme when possible, merging some sections and finally removing lots of things. This also means using the most of large screens capabilities, using responsive layouts as much as we could, even though it made the job more difficult at some point.

Article listing

The editor, it has been completely revamped, following the way opened by both Medium and Ghost. We’ve pushed aside everything that may distract you from writing. The editor goes fullscreen, and you can even pick up a white or dark background at your convenience. The post settings are 1 click away from the editor so you won’t feel lost anyway. We know how much work is left to get a really classy tool, but we’re working on it.

A new editor

The notes have got improvement. When replying to a tweet, Publify now displays the original tweet so readers can keep the context this was done.

note reply context

Users profiles have been improved to. Each user now has its own detailed page with avatar, contact links, short bio and indeed the published content.

Author page

Missing in action

The old categories VS tags separation is no more. We merged the first into the seconds as a strict categorization has no real meaning on most blogs. Don’t worry about your URLs, we took care of everything, eventually creating the redirects you needed.

The excerpt has been removed. Excerpt was meant to display a different content on the listing page and on the post itself. It was an interesting feature, but only a handful of people, if none was using it, and it made the editor more complicated than necessary.

The old Typographic theme is not part of the core anymore. It has moved to its own project and will still be maintained.

The old XMLRPC backend has been discontinued. This means Publify does not support desktop clients anymore. This choice has been motivated by the fact that the APIs it was relying had not been updated for 10 years, and that most desktop editors are not maintained anymore either. Web browsers capabilities have evolved, and you can now have a fairly decent editor with local saving without the need of a desktop application.

Under the hood

Publify has been around for 9 years now. Rails was not 1.0 yet, and some of our code was older than you can ever imagine.

Publify 8.0 got rid of most of that legacy code. The old Prototype based helpers that made Rails famous back then left the building. Prototype itself has finally been replaced by Jquery, and Rails i18n allowed the Globalize based translation system to enjoy a deserved retirement. Most helpers have been removed too, as most of them were only used in one place.

This should not affect you unless you’re running custom themes and plugins. If so, have a look at the Bootstrap theme to see how we’re now working.

That’s all folks, you can now download Publify, or give it a try on our demo platform.

Published on 02/03/2014 at 16h47 by Frédéric de Villamil, tags

Good bye Typo, welcome Publify!

It’s been scratching us for a while now, and we finally did it: Typo is no more, long live Publify! There are many reasons why we changed your favorite blogware name, leaving behind us a 7 years old brand and not always glorious history.

Typo is a stupid name for a publishing tool

Typo took its name from a Typo Tobias made into his agenda, giving him a few hours to start coding the blogware that once powered Rails official blog, but let’s be honest, it’s a stupid name for a blogging engine, a really stupid one.

Making typos is not something you would expect when writing quality content, and we indeed expect our users to produce quality content. Typos make content look dumb and their producer look careless if not illiterate.

On the other hand, even though Publify may not be the best, most original name, it means what it should mean: something meant to publish, which is not so bad after all.

Typo is unsearchable

Open your favorite search engine, and look for typo. My bet is you won’t find many things related to Typo. If you’re lucky, our main site will come on first page, but I’m not even sure it will happen.

Google brings 65,300,000 results for Typo, most of them being related to typography, Publify has only 3460 entries. I’m sure you see the point, but finding resources for Publify will become easier as time goes.

There’s already a Typo3 publishing tool

There was a CMS called Typo3 long before Typo appeared. Typo3 is an enterprise CMS developed in PHP, and many people would make the confusion. Typo3 has been around for more than 10 years, and we did not mean to overlap on that name. It actually caused more problems that it solved, because many people were asking us about Typo3.

What about my content / theme / plugins ?

The old typo:code macros won’t work anymore. They’ve been replaced by the same publify:code macros. We’re providing a migration that makes your content work with publify:code.

Your old themes should still be working. If not, just replace all occurrences of TypoPlugins by PublifyPlugins, and all occurrences of Typo by Publify.

Your homemade plugins probably won’t work, because the TypoPlugins class they inherit from doesn’t exist anymore. To fix them, replacing TypoPlugins by PublifyPlugins in your code should do the trick. Don’t forget to restart your Publify blog after doing the changes.

That said, we’re now going to go back to work to release the first Publify version during the summer. Have a nice, sunny blogging.

Published on 10/07/2013 at 14h05 by Frédéric de Villamil, tags

Typo 6.1.4 (get your booty on the floor)

It’s been only 2 weeks since we released Typo 6.1.3 and Typo 6.1.4 is already here. 2 weeks ago, we were sure that Typo was stable enough to ensure a long term release while we would work on our new major release.

3 things prevented us to do so.

First, a new Rails version was released with another important security fix. Typo 6.1.4 comes with that fix so you should definitely upgrade.

Second, we had the opportunity to fix some bugs, and that was another very good reason to release.

Three, we have done a huge documentation effort lately, and we thought it would be a good idea to have it released as well. The doc is now used to automatically deploy our Web Site on typosphere.org. Oh, and we’ve also changed our Twitter account, you can now follow us on @gettypo.

Once again, we’d like to thank our contributors Marcel M. Cary, Nicolas Blanco and randomecho for their… contribution to Typo.

Fixed bugs

Moved #defaulttextfilter so Trackback can use it (Marcel M. Cary).

Fixed typo news and latest posts date format with distanceoftimeinwords (Marcel M. Cary)

Fixed Heroku deployment Gemfile (Nicolas Blanco)

Fixes a bug where already published articles publication date would be changed by autosave (issue 141).

Fixed secret token generation on existing blog (issue 142).

Fixed an issue where textfilter showed always as ‘none’, even if set before to markdown (issue 69).

Published on 12/02/2013 at 19h48 by Frédéric de Villamil, tags

History repeating : release of Typo 6.1.3

I love how History tricks you by repeating itself. There’s a lot of irony in the way insignificant events build the perfect running gag in real life. 9 years ago, Tobias Luetke started Typo in a Starbucks because of a typo in his calendar. Today, I was in a Starbucks releasing Typo 6.1.3 because of a glitch in my agenda. History repeating.

I love free software communities too, when it stops arguing about politics and trolling licences to focus on code and releasing software for the fun of it.

Open source world is wonderful. The more active a project, the more contributors it find. Exactly 2 years ago, I was writing (in French) about how Github would kill open source software communities. I still believe a single word of it, even though Github is amazing to make project activity more visible. Typo has 1180 forks and is followed by 858 people without advertising about it. Latest release happened 2 weeks ago, and we had more contribution that I would have expected from 4 great contributors : Nicolas Bianco, Soon Van, Mcary, and Diego Elio Pettenò, who’s been packaging Typo on Gentoo for years.

Typo 6.1.3 is probably the latest of the 6.1 series, and a bug fixing only release. We’re now going to work on Typo 6.2, a feature based release.


For a comprehensive list of fixes, please refer to Typo 6.1.3 Changelog.

The biggest contribution was pushed by Nicolas Bianco. It fixes file upload on Amazon S3. His work andgreat ideas make Typo easier to use on Heroku than ever.

Soon Van has been doing a great work on i18n, documentation and interface consistency.

Diego Elio Pettenò fixed various plugins and text filters that make use of Flickr API.

Mcary fixed live search plugin and behavior consistency within the admin interface.

Closed tickets

Ticket nº86 : Media list did not reload after uploading a resource.

Ticket nº103 : Fixes a security issue by changing the scret token at setup time. Displays a warning message when default secret token is used.

Ticket nº123 : fixes the links available on the dashboard for both contributors and publishers.

Ticket nº124 : Fixes the html editor look and feel when the window gets too small.

Ticket nº129 : the default theme would not take all the blog options into account.

Published on 01/02/2013 at 08h06 by Frédéric de Villamil, tags

Powered by Publify | Photo Startup stock photos