PHPackages                             tolkien/tolkien - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. tolkien/tolkien

ActiveLibrary[Framework](/categories/framework)

tolkien/tolkien
===============

Simple Blogging Engine inspired by Jekyll

v0.5.3(12y ago)7414[1 issues](https://github.com/glendmaatita/Tolkien/issues)MITPHP

Since Sep 20Pushed 12y agoCompare

[ Source](https://github.com/glendmaatita/Tolkien)[ Packagist](https://packagist.org/packages/tolkien/tolkien)[ RSS](/packages/tolkien-tolkien/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (7)Used By (0)

Tolkien
=======

[](#tolkien)

Tolkien is a simple static web generator (especially for blog) mainly inspired by Jekyll. Tolkien is purely written in PHP and can be used as a composer package.

Requirement
-----------

[](#requirement)

- Minimum PHP &gt;= 5.3.\*
- Very Recommended to use PHP &gt;= 5.4 because Tolkien relies on PHP built-in webserver to run your static web page directly via Tolkien 'serve' command

Installation
------------

[](#installation)

The best way to install Tolkien is to use Composer to install it. Add this following requirement section below to your composer.json file

```
{
    "require": {
        "tolkien/tolkien": "dev-master"
    }
}

```

and then run

```
php composer.phar install

```

Basic Usage
-----------

[](#basic-usage)

Once Tolkien installed in our project directory as a composer package, we can directly run some commands to use it. For help &amp; command informations, run

```
vendor\bin\tolkien

```

#### Initialization

[](#initialization)

The first thing we must do is create our blog. For example, if we want to create a blog named **myblog**, then we use this command below

```
vendor\bin\tolkien init myblog

```

It will create some essential folders inside **myblog** in our project directory, such as

```
_assets    // put our website assets like css, js or image files here
_layouts   // layout for post/page will be placed here
_drafts    // post or page draft
_posts     // our post article is placed here
_pages     // our page is placed here
_sites     // our static website will be placed here
config.yml // main config file

```

We can add some informations about our web inside config.yml file. Look at this config.yml example below. This config below is generated after we run the initialization command

```
config:
    name: myblog
    url: /
    title: Your Blog Title
    tagline: Your Blog Tagline
    pagination: 10
dir:
    post: myblog/_posts
    page: myblog/_pages
    draft: myblog/_drafts
    site: myblog/_sites
    asset: myblog/_assets
    layout: myblog/_layouts
authors:
    tolkien:
        name: 'John Ronald Reuel Tolkien'
        email: tolkien@kodetalk.com
        facebook: Tolkien
        twitter: '@tolkien'
        github: Tolkien
        signature: 'Creator of LoTR Trilogy'

```

config.yml uses YAML configuration format. For now, make sure we just only change title and tagline in config section, and authors section. Maybe you want to change author's content with your bio or add your co-author. My own will look like

```
// other config section
authors:
    glend:
        name: 'Glend Maatita'
        email: glend@kodetalk.com
        facebook: Glend Maatita
        twitter: '@glend_maatita'
        github: glendmaatita
        signature: 'Just another author'
    benny:
        name: 'Benny Maatita'
        email: benny@kodetalk.com
        facebook: Benny Maatita
        twitter: '@benny_maatita'
        github: bennymaatita
        signature: 'Just another author like Glend'

```

#### Generate Post

[](#generate-post)

If we want to write an article for our **myblog**, then we create a post. For example, to create a post titled ***Introduction to PHP***, using layout ***post***, authored with ***glend*** we run this command

```
vendor\bin\tolkien generate:post --author=glend --layout=post myblog "Introduction to PHP"

```

It will create a file with format : *date-title.markdown* inside **\_posts** folder. The generated file's content has 2 section : header and body. Header is content with YAML format beetwen --- . Look at this generated file's content

```
---
type: post
layout: post
title: Introduction to PHP
date: 2013-09-20
author: glend
categories: category1
---

```

*type: post* indicates that the file is a post file. *layout: post* means that we use post layout inside **\_layouts** folder. *title* is your Post's title, you can change the title if you want.

Author is an alias of author taken from the config file (author section). And categories section will define your post's categories. You can add more than one category here, separated with comma (','). That's a header.

For body section, you can add the body below the header. We can use Markdown which is highly recommended for body format. But you can also use HTML format. To use HTML format for the post body, you **must** change the post file extension to **.html**. So based on generated example file above, you must change its name to *date-title.html*.

For another options and information run :

```
vendor\bin\tolkien generate:post -h

```

#### Generate Page

[](#generate-page)

Page is just like Post, but without author, categories, and date section on its header. if we want to create a page for our **myblog** web, for example Contact page with ***page*** layout, we simply run this command below

```
vendor\bin\tolkien generate:page --layout=page myblog "Contact Us"

```

The command above will create a file with format title.markdown inside **\_pages** folder. Its content is same with Post, has two section (header and body) and you can add the body below the header. The body format is Markdown, but you can use HTML format with the same rule as Post.

For another options and information to generate page, run :

```
vendor\bin\tolkien generate:page -h

```

#### Compile

[](#compile)

Compile is Tolkien's command for generate our static web page based on posts and pages file that we created before. The generated web page will be placed under **\_sites** folder. Look at this compile command below

```
vendor\bin\tolkien compile blog

```

Check on *\_sites* folder and we will find our assets (css, js, images) files, page file, and post file become a static web page

#### Serve

[](#serve)

Serve command relies on PHP Built-in webserver to run our static web page directly. Just type this command below and we can access our beloved **myblog** page with url : **localhost:3000**

```
vendor\bin\tolkien serve myblog

```

Layout
------

[](#layout)

To create layout files under **\_layout**, Tolkien use [Twig](http://twig.sensiolabs.org/) template engine which is awesome. In other words, you can use all Twig's features including Filters, Functions, Control Structure, Expression, etc.

The default layout is available under **\_layout**, but you are totally free to create your own layout. Just use Twig template engine, and some variables below.

Variable
--------

[](#variable)

Tolkien has several variables that you can pass to your layout files (Twig template) inside **\_layouts**, such as

#### Site Variables

[](#site-variables)

```
site.url            // URL of your web. Defined at config.yml
site.title          // Title of your web. Defined at config.yml
site.tagline        // Tagline. Defined at config.yml
site.posts          // Get all posts
site.pages          // Get all pages
site.categories     // Get all posts's categories

```

#### Category Variables

[](#category-variables)

```
category.url    // URL for category page. This page may contains a list of post of certain category
category.name   // Category's name
category.posts  // get all category's posts. A list of post with certain category

```

#### Post Variables

[](#post-variables)

```
post.title      // Get Post's title
post.body       // Body
post.url        // Post's URL
post.layout     // Layout
post.excerpt    // Get post's excerpt
post.categories // Get post's categories
post.publishDate    // Publish date

```

#### Post's Author

[](#posts-author)

```
post.author.name        // Name of Post's Author
post.author.email       // Author's email
post.author.signature   // Signature
post.author.facebook
post.author.twitter
post.author.github

```

#### Page Variables

[](#page-variables)

```
page.title      // Page's Title
page.body       // Body
page.url        // Page's URL

```

### Pagination Variables

[](#pagination-variables)

```
pagination.posts    // Get all post in a particular pagination
pagination.previousPage // Get previous page in pagination
pagination.nextPage // Get next page
pagination.numberPage   // get current number of this pagination
pagination.url      // Pagination's URL

```

Index HTML
----------

[](#index-html)

Index or Home is the first page that always will be opened when a visitor come to your website. Index is just an ordinary Page with special layout. To create index, just run **generate page** command like below

```
vendor\bin\tolkien generate:page --layout=index myblog index

```

then, change the layout to index

```
---
type: page
layout: index
title: Home
---

```

Pagination
----------

[](#pagination)

Pagination is included by default in Tolkien. See the config.yml file and you'll find Tolkien had set a number of post (10 by default) in a pagination for you. You can change this number. ***Remember***, dont delete this pagination section, use if you want to use pagination or ignore if you dont want to use.

Normally, we use this feature on index page. So, lets change your index page to be like below, for example

```
{% for post in pagination.posts %}
// code for display a list of post in a particular pagination
{% endfor %}
{% if pagination.previousPage is not null %}

    Previous

{% endif %}
{% if pagination.nextPage is not null %}

    Next

{% endif %}

```

Deployment
----------

[](#deployment)

Check [Heston](http://github.com/glendmaatita/heston/) on Github for easy deployment using FTP. If you use Heston, just run this command below to deploy your site that generated with Tolkien to your FTP Server

```
vendor\bin\heston ftp://username:password@ftp.domain.tld:port myblog/_sites/ "_your_comment_"

```

Other
-----

[](#other)

For documentation in Bahasa (Indonesian) Version, please refer to [Kodetalk](http://www.kodetalk.com/tolkien.html). Kodetalk's source code using Tolkien on [Github](http://github.com/KodeTalk/website)

License
-------

[](#license)

Tolkien is released under the MIT License. Check License file for detail

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

4

Last Release

4596d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4a6bb5a011fcb0de13fbc255a151aebf040162f64e6887ee8873a2c54271f32?d=identicon)[glendmaatita](/maintainers/glendmaatita)

---

Top Contributors

[![glendmaatita](https://avatars.githubusercontent.com/u/966956?v=4)](https://github.com/glendmaatita "glendmaatita (63 commits)")[![soldatodev](https://avatars.githubusercontent.com/u/25558668?v=4)](https://github.com/soldatodev "soldatodev (18 commits)")[![entung](https://avatars.githubusercontent.com/u/5677964?v=4)](https://github.com/entung "entung (16 commits)")[![mul14](https://avatars.githubusercontent.com/u/113989?v=4)](https://github.com/mul14 "mul14 (3 commits)")

### Embed Badge

![Health badge](/badges/tolkien-tolkien/health.svg)

```
[![Health](https://phpackages.com/badges/tolkien-tolkien/health.svg)](https://phpackages.com/packages/tolkien-tolkien)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[october/rain

October Rain Library

1601.7M63](/packages/october-rain)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
