diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0495d7d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+pile.db
+vendor
diff --git a/www/_templates/.htaccess b/www/_templates/.htaccess
new file mode 100644
index 0000000..14249c5
--- /dev/null
+++ b/www/_templates/.htaccess
@@ -0,0 +1 @@
+Deny from all
\ No newline at end of file
diff --git a/www/_templates/Template.php b/www/_templates/Template.php
new file mode 100644
index 0000000..2739e6f
--- /dev/null
+++ b/www/_templates/Template.php
@@ -0,0 +1,31 @@
+<?php
+
+// All credit goes to Chad Minick:
+// http://chadminick.com/articles/simple-php-template-engine.html
+
+class Template {
+    private $vars  = array();
+
+    public function __get($name) {
+        return $this->vars[$name];
+    }
+
+    public function __set($name, $value) {
+        if($name == 'view_template_file') {
+            throw new Exception("Cannot bind variable named 'view_template_file'");
+        }
+        $this->vars[$name] = $value;
+    }
+
+    public function render($view_template_file) {
+        if(array_key_exists('view_template_file', $this->vars)) {
+            throw new Exception("Cannot bind variable called 'view_template_file'");
+        }
+        extract($this->vars);
+        ob_start();
+        include($view_template_file);
+        return ob_get_clean();
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/www/_templates/front_doc_listing.php b/www/_templates/front_doc_listing.php
new file mode 100644
index 0000000..dbdefc4
--- /dev/null
+++ b/www/_templates/front_doc_listing.php
@@ -0,0 +1,16 @@
+<div class="text tag-text">
+    <h1><?= $tag["Name"] ?></h1>
+    <p class="tag-desc"><?= $tag["Description"] ?></p>
+</div>
+
+<?php foreach($docs as $doc): ?>
+    <div class="text doc-item">
+        <a class="doc-item-link" href="<?= $doc["URL"] ?>">🔗</a>
+        <a href="?item=<?= $doc["ID"]?>">
+            <div class="doc-item-text">
+                <h2><?= $doc["Title"]?></h2>
+                <h3><?= $doc["Author"] . " " . $doc['date']?></h3>
+            </div>
+        </a>
+    </div>
+<?php endforeach; ?>
\ No newline at end of file
diff --git a/www/_templates/front_doc_overview.php b/www/_templates/front_doc_overview.php
new file mode 100644
index 0000000..aa2001e
--- /dev/null
+++ b/www/_templates/front_doc_overview.php
@@ -0,0 +1,14 @@
+<div class="text document">
+    <h1><?= $doc["Title"] ?></h1>
+    <h2><?= $doc["Author"] ?></h2>
+    <h3>Published: <?= $doc["Published"] ?></h3>
+    <h3 class="doc-taglist">Tags:
+        <?
+        foreach($tags as $tag){
+            echo '<li><a href="?tag=' . $tag["ID"] . "\">" . $tag["Name"] . "</a></li>";
+        }
+        ?>
+    </h3>
+    <p class="doc-description"><span class="doc-description-intro">Description: </span><?= $doc["Description"] ?></p>
+    <div class="doc-link"><span class="doc-link-intro">Access file at: </span><a href="<?= $doc["URL"] ?>"><?= $doc["URL"] ?></a></div>
+</div>
\ No newline at end of file
diff --git a/www/_templates/front_intro.php b/www/_templates/front_intro.php
new file mode 100644
index 0000000..74853a5
--- /dev/null
+++ b/www/_templates/front_intro.php
@@ -0,0 +1,5 @@
+<div class="text">
+    <p class="intro"> This site is the sdbs pile, where we upload the stuff we consider important to the larger conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to self-determination, counter-culture and such...</p>
+    <p class="intro czech">Tohle je hromádka zajímavýho materiálu co něco znamená v kontextu sdbs - budeme sem postupně dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
+    <p class="intro sign">/-\</p>
+</div>
\ No newline at end of file
diff --git a/www/_templates/front_wrap.php b/www/_templates/front_wrap.php
new file mode 100644
index 0000000..b28cbfe
--- /dev/null
+++ b/www/_templates/front_wrap.php
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <meta charset="utf-8">
+        <meta http-equiv="X-UA-Compatible" content="IE=edge">
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+
+        <title>The /-\ pile</title>
+
+        <link rel="stylesheet" type="text/css" href="assets/main.css">
+
+        <!-- Piwik -->
+        <script type="text/javascript">
+            var _paq = _paq || [];
+            _paq.push(['trackPageView']);
+            _paq.push(['enableLinkTracking']);
+            (function() {
+                var u="//www.sdbs.cz/piwik/";
+                _paq.push(['setTrackerUrl', u+'piwik.php']);
+                _paq.push(['setSiteId', '2']);
+                var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+                g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+            })();
+        </script>
+        <noscript><p><img src="//www.sdbs.cz/piwik/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
+        <!-- End Piwik Code -->
+    </head>
+    <body>
+
+        <div id="sidebar">
+            <div id="sidebar-head">
+                <h1><a href="..">The /-\ pile</a></h1>
+            </div>
+            <div id="sidebar-taglist">
+                <ul>
+                    <li id="sidebar-taglist-top"><a href="?tag=*">ALL (<?= $tag_count ?>)</a></li>
+                    <?
+                        foreach($tags as $tag){
+                            echo '<li><a href="?tag=' . $tag['href'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
+                        }
+                    ?>
+                </ul>
+            </div>
+        </div>
+
+        <div id="content">
+            <?php echo $content ?>
+        </div>
+
+        <div id="login">
+            <form method="post">
+                <input type="text" name="username" id="login-user"></input>
+            <input type="password" name="password" id="login-pass"></input>
+        <button type="submit" id="login-button">></button>
+        </form>
+    </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/www/assets/main.css b/www/assets/main.css
new file mode 100644
index 0000000..dbfafc4
--- /dev/null
+++ b/www/assets/main.css
@@ -0,0 +1,218 @@
+@font-face {
+    font-family: Prociono;
+    src: url(Prociono.woff);
+}
+
+*, *:before, *:after {
+  -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
+}
+
+body {
+    font-family: Prociono;
+    margin: 0;
+    padding: 0;
+    position: relative;
+    height: 100%;
+    background: #f2f2f2;
+}
+
+a {
+    color: #f2f2f2;
+    text-decoration: none;
+}
+
+#sidebar {
+    font-family: Prociono, serif;
+}
+
+#sidebar-head {
+    background-color: #202020;
+    color: white;
+    
+    background-image: url(/assets/pile_white.svg);
+    background-repeat: no-repeat;
+    background-position: center 1.5em;
+    background-size: 50%;
+    
+    text-align: center;
+}
+ 
+#sidebar-head > h1 {
+    padding: 0.5em;
+    padding-top: 6em;
+    margin: 0;
+    margin-bottom: 1rem;
+}
+
+#sidebar-taglist {
+    background: #202020;
+    color: #f2f2f2;
+    padding: 1rem 0 1rem 0;
+}
+
+#sidebar-taglist > ul > li {
+    list-style: none;
+    font-size: 14pt;
+    margin-bottom: .5em;
+}
+
+#sidebar-taglist > ul > li:before {
+    content: "/ ";
+}
+
+#sidebar-taglist-top:before {
+    content: "\\ " !important;
+}
+
+#sidebar-taglist a {
+    color: #f2f2f2;
+    text-decoration: none;
+}
+
+#content {
+    font-size: 14pt;
+}
+
+.text {
+    background: #202020;
+    color: #f2f2f2;
+    padding: 1rem;
+    margin: 0 0 1rem 0;
+}
+
+.doc-item-text {
+    display: inline-block;
+    margin-right: 3em;
+}
+
+.doc-item h2 {
+    font-size: 14pt;
+    font-weight: normal;
+    margin: 0;
+}
+
+.doc-item h3 {
+    margin: 0;
+    font-size: 11pt;
+    font-weight: normal;
+    font-style: italic;
+}
+
+.doc-item-link {
+    display: inline-block;
+    font-size: 18pt;
+    font-weight: bold;
+    float: right;
+    position: relative;
+    top: 7px;
+    right: 1em;
+}
+
+.tag-text
+
+.document h1 {
+    margin: 0;
+    font-size: 24pt;
+}
+
+.document h2 {
+    margin: 2pt 0 2pt 0;
+    font-style: italic;
+    font-weight: normal;
+    font-size: 16pt;
+}
+
+.document h3 {
+    margin: 2pt 0 2pt 0;
+    font-weight: normal;
+    font-size: 16pt;
+}
+
+.doc-taglist li {
+    list-style: none;
+    display: inline-block;
+}
+
+.doc-taglist li a {
+    text-decoration: underline;
+}
+
+.doc-taglist li:after {
+    content: "/";
+}
+
+.doc-taglist li:last-of-type:after {
+    content: "";
+}
+
+.doc-description-intro, .doc-link-intro {
+    font-weight: bold;
+}
+
+.doc-link-intro:before {
+    content: "➜ ";
+}
+
+.doc-link a {
+    text-decoration: underline;
+}
+
+@media screen and (min-width: 64em ) {
+    #sidebar {
+        position: absolute;
+        top: 0;
+        left: 2rem;
+        width: 14rem;
+    }
+    
+    #content {
+        margin: 2rem 2rem 0 18rem;
+        padding: 0 0 2rem 0;
+    } 
+}
+
+@media screen and (max-width: 64em ) { 
+    #sidebar-head {
+        background-position: 14%;
+        background-size: 4rem;
+        height: 7rem;
+        margin-bottom: 1rem;
+    }
+    
+    #sidebar-head > h1 {
+        padding-top: 1.5rem;
+        font-size: 3rem;
+    }
+    
+    #sidebar-taglist {
+        margin-bottom: 1rem;
+    }
+}
+
+#login {
+    position: absolute;
+    bottom: 0;
+    right: 2rem;
+}
+
+#login input {
+    height: 14pt;
+    border: 1px solid lightgray;
+}
+
+#login button {
+    height: 14pt;
+    font-size: 8pt;
+    border: 1px solid lightgray;
+    background: white;
+}
+
+.czech {
+    font-size: 12pt;
+}
+
+.sign {
+    font-weight: bold;
+    font-size: 16pt;
+    margin: 0;
+}
\ No newline at end of file
diff --git a/www/assets/pile_white.svg b/www/assets/pile_white.svg
new file mode 100644
index 0000000..2bd67fc
--- /dev/null
+++ b/www/assets/pile_white.svg
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="6.61026mm"
+   height="8.4858389mm"
+   viewBox="0 0 23.422181 30.067933"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="pile logo_white.svg">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="16"
+     inkscape:cx="18.340942"
+     inkscape:cy="16.159642"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     fit-margin-top="0"
+     fit-margin-left="0"
+     fit-margin-right="0"
+     fit-margin-bottom="0"
+     inkscape:window-width="1680"
+     inkscape:window-height="988"
+     inkscape:window-x="1272"
+     inkscape:window-y="-8"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Vrstva 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-15.158962,-12.023409)">
+    <g
+       transform="translate(-126.20458,-71.853004)"
+       style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="text4254-4">
+      <path
+         d="m 141.80015,113.67837 22.1058,0 c 0,-0.4 0.19143,-7.64 0.35143,-9.28 l -1.48,0 -0.71884,2.94125 c -0.4,1.52 -1.24089,3.53125 -1.90607,4.12107 -0.52,0.44 -5.51232,0.45768 -6.11232,0.45768 l -0.84,0 c -2.88,0 -3.92,-0.64 -3.92,-1.56 0,-0.36 0.08,-17.400002 0.28,-23.120002 0.04,-1.28 1.4,-1.44 3.28,-1.56 l 0.56,-0.04 0,-1.48 -11.6,0 0,1.48 0.56,0.04 c 1.88,0.12 2.68,0.28 2.76,1.56 0.24,7.72 0.28,22.160002 0.28,23.120002 0,1.48 -1.48,1.68 -3.6,1.84 z"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Prociono;-inkscape-font-specification:Prociono;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+         id="path4321"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccccsssccccccccscc" />
+    </g>
+    <g
+       transform="matrix(1.0042803,0,0,0.99573794,-126.20458,-71.853004)"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:39.83314133px;line-height:125%;font-family:Prociono;-inkscape-font-specification:Prociono;letter-spacing:0px;word-spacing:0px;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.49791428;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="text4246-5">
+      <path
+         d="m 141.01002,114.16599 13.62293,0 0,-1.35432 -1.51366,-0.1195 c -2.11115,-0.15934 -4.38164,-0.3585 -4.38164,-1.83233 0,-0.31866 0.0398,-4.81981 0.0797,-10.15745 0.99582,0.43817 2.78832,0.63733 4.26214,0.63733 7.60813,0 10.75495,-5.576639 10.75495,-8.723457 0,-3.903648 -1.63316,-8.086127 -8.20563,-8.086127 l -0.79666,0 c -1.87216,0 -1.82308,0.08449 -7.91755,0.08449 -2.11116,0 -4.88824,0.03242 -5.62572,0.154505 l -0.0445,1.204823 0.55767,0.03983 c 1.87121,0.133646 2.7531,0.547836 2.79293,1.822496 0.0797,2.708654 0.1195,6.134304 0.1195,9.559954 0,8.086136 -0.0797,12.109286 -0.1195,13.463606 -0.0398,1.51366 -1.63316,1.71283 -3.58498,1.83233 l 0,1.47382 z m 7.84713,-16.01292 c 0.0398,-3.42565 0.1195,-8.444626 0.19916,-10.754948 l 0.43817,-0.438165 c 1.03566,-0.358498 3.98331,-0.477997 5.6563,-0.477997 0.239,0 0.717,0.159332 1.15517,0.358498 3.02731,1.473826 3.06715,4.301979 3.06715,6.452969 0,2.071323 -0.15933,6.054637 -5.93514,6.054637 -2.35016,0 -3.94348,-0.63733 -4.58081,-1.194994 z"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Prociono;-inkscape-font-specification:Prociono;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.49791428;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+         id="path4318"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccscsssssccscscccccccscssc" />
+    </g>
+    <g
+       transform="matrix(0.99946441,0,0,1.0005359,-126.20458,-71.853004)"
+       style="font-style:normal;font-weight:normal;font-size:40.02097321px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="text4258-2">
+      <path
+         d="m 141.70753,113.63314 22.2854,-0.0158 c 0,-0.40021 0.20011,-7.644 0.36019,-9.28486 l -1.48078,0 -0.56029,2.16113 c -0.40021,1.5208 -1.04054,4.0021 -2.04107,4.88256 -0.44023,0.36019 -3.12164,0.48025 -4.2022,0.48025 -4.80252,0 -6.6835,-0.24013 -6.6835,-1.56082 0,-0.36019 0,-5.56291 0.08,-11.486017 1.16061,0.120063 7.16375,-0.160084 8.80461,1.040545 l 0.68036,0 0.40021,-2.961552 c -0.84044,0.04002 -7.48392,0.200105 -9.84516,0.200105 0.04,-3.441804 0.08,-7.203775 0.16008,-9.524992 0.04,-1.160608 1.00053,-1.360713 3.28172,-1.360713 1.76093,0 4.08214,0 5.04265,0.120063 0.60031,0.08004 0.9605,0.120063 1.48077,0.240126 0.40021,0.280147 0.52027,0.640336 0.64034,1.040545 0.04,0.08004 0.68035,3.241699 0.88046,4.322265 l 1.36071,0 c 0.04,-0.560293 0.9605,-6.963649 1.08057,-7.40388 l -0.48025,-0.44023 c 0,0 -10.32542,0.04002 -10.52552,0.04002 -1.20063,0.08004 -3.23191,-0.0032 -5.03285,-0.0032 -2.08109,0 -4.42,0.09844 -5.50057,0.01839 l 0.008,1.425563 0.5603,0.04002 c 1.84096,0.120063 2.6814,0.280147 2.72142,1.560818 0.12007,2.921531 0.16009,6.483397 0.16009,9.925201 0,6.123213 -0.12007,11.926253 -0.16009,13.206923 0,1.5208 -1.4745,1.73668 -3.47554,1.85675 3e-5,0.49358 -2e-5,0.98729 -6e-5,1.48079 z"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Prociono;-inkscape-font-specification:Prociono;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+         id="path4315"
+         inkscape:connector-curvature="0"
+         sodipodi:nodetypes="ccccccssccccccsccccccccsccccsccc" />
+    </g>
+    <g
+       transform="translate(-126.20458,-71.853004)"
+       style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="text4250-8">
+      <path
+         inkscape:connector-curvature="0"
+         d="m 149.03309,113.67837 11.08,0 0,-1.48 c -2.08,-0.16 -3.6,-0.36 -3.6,-1.84 0,-0.36 0.08,-17.400002 0.28,-23.120002 0.04,-1.28 0.88,-1.44 2.76,-1.56 l 0.56,-0.04 0,-1.48 -11.08,0 0,1.48 0.56,0.04 c 1.88,0.12 2.72,0.28 2.76,1.56 0.24,7.96 0.28,22.800002 0.28,23.120002 0,1.52 -1.6,1.72 -3.6,1.84 l 0,1.48 z"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Prociono;-inkscape-font-specification:Prociono;fill:none;fill-opacity:0;stroke:#ffffff;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+         id="path4312" />
+    </g>
+  </g>
+</svg>
diff --git a/www/index.php b/www/index.php
new file mode 100644
index 0000000..eb353f1
--- /dev/null
+++ b/www/index.php
@@ -0,0 +1,86 @@
+<?php
+require '_templates/Template.php';
+
+
+$db = new SQLite3("pile.db");
+
+$ret_count = $db->query("SELECT count(ID) FROM Documents")->fetchArray(SQLITE3_NUM);
+$count = $ret_count[0];
+
+$tag_query = "SELECT 
+                   ID, Name, count(Document)
+                FROM
+                   Tags t
+                LEFT OUTER JOIN 
+                   DocumentstoTags d ON t.ID = d.Tag
+                GROUP BY Name
+                ORDER BY count(Document) DESC, Name";
+$tags_ret = $db->query($tag_query);
+$tags = [];
+while ($row = $tags_ret->fetchArray(SQLITE3_NUM)) {
+    array_push($tags, array(
+        'href' => $row[0],
+        'name' => $row[1],
+        'count' => $row[2]
+    ));
+}
+
+if (isset($_GET["item"])) {
+    $stmt_doc = $db->prepare("SELECT * FROM Documents WHERE ID = :id");
+    $stmt_doc->bindValue(":id", $_GET["item"], SQLITE3_INTEGER);
+    $doc = $stmt_doc->execute()->fetchArray(SQLITE3_ASSOC);
+
+    $stmt_tags = $db->prepare("SELECT t.ID, t.Name FROM Tags t
+                                                JOIN DocumentsToTags dt ON t.ID = dt.Tag
+                                                JOIN Documents d on t.ID = dt.Document
+                                            WHERE d.ID = :id");
+    $stmt_tags->bindValue(":id", $_GET["item"], SQLITE3_INTEGER);
+    $ret = $stmt_tags->execute();
+    $doc_tags = [];
+    while ($tag = $ret->fetchArray(SQLITE3_ASSOC)) {
+        array_push($doc_tags, $tag);
+    }
+
+    $doc_template = new Template();
+    $doc_template->doc = $doc;
+    $doc_template->tags = $doc_tags;
+    $content = $doc_template->render('front_doc_overview.php');
+} elseif (isset($_GET["tag"])) {
+    if ($_GET["tag"] == "*"){
+        $query = "SELECT ID, Title, Author, Published, URL FROM Documents";
+        $doc_ret = $db->query($query);
+    } else {
+        $stmt = $db->prepare("SELECT
+                                    ID, Title, Author, Published, URL
+                                FROM
+                                   Documents d
+                                LEFT OUTER JOIN 
+                                   DocumentsToTags t ON d.ID = t.Document
+                                   WHERE Tag == :tag");
+        $stmt->bindValue(":tag", $_GET["tag"], SQLITE3_INTEGER);
+        $doc_ret = $stmt->execute();
+    }
+    $docs = [];
+    while ($doc = $doc_ret->fetchArray(SQLITE3_ASSOC)) {
+        $doc['date'] = empty($doc["Published"]) ? "" : "(" . $doc["Published"] . ")";
+        array_push($docs, $doc);
+    }
+
+    $stmt = $db->prepare("SELECT Name, Description FROM Tags WHERE ID == :tag");
+    $stmt->bindValue(":tag", $_GET["tag"], SQLITE3_INTEGER);
+    
+    $doc_list_template = new Template();
+    $doc_list_template->tag = $stmt->execute()->fetchArray(SQLITE3_ASSOC);
+    $doc_list_template->docs = $docs;
+    $content = $doc_list_template->render('front_doc_listing.php');
+} else {
+    $intro_template = new Template();
+    $content = $intro_template->render('front_intro.php');
+}
+
+$page = new Template();
+$page->tag_count = $count;
+$page->tags = $tags;
+$page->content = $content;
+echo $page->render('front_wrap.php');
+?>
\ No newline at end of file