diff --git a/compiler.py b/compiler.py
index ffe7cec2bd18e615227808e04a214cb38dd7a6d1..ad5d3e597923ec69a47787c942e777532c1280cd 100644
--- a/compiler.py
+++ b/compiler.py
@@ -10,6 +10,7 @@ from distutils.dir_util import copy_tree
 import jinja2
 import yaml
 from mdcomp import convert_text
+import filters
 
 
 def get_from_filesystem(template_names, template_dir=".", data_dir="../data"):
@@ -20,6 +21,9 @@ def get_from_filesystem(template_names, template_dir=".", data_dir="../data"):
     template_loader = jinja2.FileSystemLoader(searchpath=template_dir)
     template_env = jinja2.Environment(loader=template_loader)
 
+    # We need to register our custom filters.
+    template_env.filters["sort_cards"] = filters.sort_cards
+
     templates = list(map(template_env.get_template, template_names))
     data = get_associated_data(template_names, data_dir)
 
diff --git a/filters.py b/filters.py
new file mode 100644
index 0000000000000000000000000000000000000000..2088f84b8b99ff8c0645d0c668749c19e96840d1
--- /dev/null
+++ b/filters.py
@@ -0,0 +1,33 @@
+"""
+Some simple macros that are used to e.g. sort things within the jinja
+templates. For the relevant documentation please see:
+
+http://jinja.pocoo.org/docs/2.9/api/#custom-filters
+
+Created 26-09-2017 by Josh Borrow (joshua.borrow@durham.ac.uk)
+"""
+
+import dateutil.parser as dp
+
+def sort_cards(cards):
+    """
+    Sort the cards by date. 'cards' should have the following structure:
+    [
+       {
+         ...
+         date: "date"
+       },
+    ]
+    
+    A list will be returned where the cards are sorted by date.
+    """
+
+    dates = [
+        dp.parse(card["date"]) for card in cards
+    ]
+
+    _, cards = zip(*sorted(zip(dates, cards)))
+
+    # We want the newest to appear first.
+    return reversed(cards)
+
diff --git a/templates/pubs.html b/templates/pubs.html
index fe53e9163d85c449d601327d4af2bdd963aef0e5..6b0c637c0816c1dda7e6838ce75e7de633e1fe2f 100644
--- a/templates/pubs.html
+++ b/templates/pubs.html
@@ -9,7 +9,7 @@
     <div class="container">
         {{ helper.navbar(navbar, link) }}
         <div class="cards">
-            {% for card in cards %}
+            {% for card in cards|sort_cards %}
                 <div class="card">
                     <a class="card-content" href="{{ card.link }}">
                         {% if card.img %}
@@ -29,4 +29,4 @@
             {% endfor %}
         </div>
     </div>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/templates/talks.html b/templates/talks.html
index 8d968c48d1609f72ca28446e52942b9957f4ea10..f23ca7c86a810b9843f9296ab7c74fbc307e08ca 100644
--- a/templates/talks.html
+++ b/templates/talks.html
@@ -6,7 +6,7 @@
     <div class="container">
         {{ helper.navbar(navbar, link) }}
         <div class="cards">
-            {% for card in cards %}
+            {% for card in cards|sort_cards %}
                 <div class="card">
                     <div class="card-content">
                         <div>
@@ -40,4 +40,4 @@
     <div class="bottom-padder">
         {# we need this to prevent overlapping #}
     </div>
-{% endblock %}
\ No newline at end of file
+{% endblock %}