Building Static Websites with Sculpin

PHPSW - October 2015

By Oliver Davies / @opdavies

opdavies

  • Senior Developer at Microserve
  • Drupaler who uses Sculpin

What is Sculpin?

  • Static site generator
  • CLI tool
  • Built on Symfony’s HttpKernel
  • HTML + Markdown + Twig > static site

What do I use it For?

  • My personal website
  • HTML prototypes and testing
  • Learning YAML and Twig (and maybe some Symfony)

Installation


$ curl -O https://download.sculpin.io/sculpin.phar
$ chmod +x sculpin.phar
$ mv sculpin.phar /usr/local/bin/sculpin
					

Or use the Sculpin Ansible role. :)

Using Sculpin

  • Configuration lives in app/config
  • Source code lives in source

Generate a Site

$ sculpin generate builds the things

  • --server
  • --watch
  • --env

source/index.md


---
layout: default
title: Hello!
---

Hi, [PHPSW](https://phpsw.uk)!
						

Super Simple Sculpin Site

Configuration

  • Stored in app/config
    • sculpin_site.yml
    • sculpin_site_ENV.yml
  • Key-value pairs

---
title: My PHPSW talk
foo: bar
main_menu_links:
    - { title: About, href: / }
    - { title: Talks, href: /talks/ }
						

Simple Settings

Environment Settings

YAML Front Matter


---
layout: post
title: New Blog Post
draft: yes
---

# My New Blog Post
						

More Front Matter


---
layout: post
title: New Blog Post
draft: yes
tags:
    - drupal
    - sculpin
    - phpsw
---

# My New Blog Post
						

Even More Front Matter


---
layout: post
title: New Blog Post
draft: yes
tags:
    - drupal
    - sculpin
    - phpsw
tweets: yes
foo: bar
---

# My New Blog Post
						

Using on Pages


---
...
testimonials:
    - { name: ..., role: ..., text: ..., url: ... }
    - { name: ..., role: ..., text: ..., url: ... }
    - { name: ..., role: ..., text: ..., url: ... }
---

{% for testimonial in page.testimonials %}
    

{{ testimonial.name }} - {{ testimonial.role }}

{{ testimonial.text }}

{% endfor %}

Content Types

Sculpin does custom content types!


# app/config/sculpin_kernel.yml

sculpin_content_types:
    projects:
        permalink: projects/:slug_title/
						

Accessing Custom Content Types


---
title: My Projects
layout: default
use:
    - projects
---
{% for project in data.projects %}
    

{{ project.title }}

{% endfor %}

Extending Sculpin

  • Custom (Symfony) bundles
  • Twig extensions
  • Other Symfony components or PHP libraries
## Resources [http://bit.ly/sculpin-twig-resources](http://bit.ly/sculpin-twig-resources)
## Questions?
## Feedback [https://joind.in/talk/view/15486](https://joind.in/talk/view/15486)