Home >Backend Development >PHP Tutorial >Sculpin Extended: Customizing Your Static Site Blog

Sculpin Extended: Customizing Your Static Site Blog

Jennifer Aniston
Jennifer AnistonOriginal
2025-02-14 08:32:12249browse

This article guides PHP developers through building a blog using Sculpin, a PHP-based static site generator. It emphasizes the advantages of using a familiar language for blog development, simplifying the addition of functionalities.

Sculpin Extended: Customizing Your Static Site Blog

Key Benefits:

  • PHP Familiarity: Leverage existing PHP skills for streamlined blog development.
  • Easy Setup: Quick installation and blog creation using the Sculpin Blog Skeleton.
  • Simple Configuration: Effortless blog customization via sculpin_site.yml and sculpin_kernel.yml.
  • Flexible Customization: Edit HTML templates and utilize Twig for dynamic content rendering.
  • GitHub Pages Deployment: Seamlessly deploy your blog to GitHub Pages.
  • Enhanced Functionality: Integrate features like Disqus comments and pagination.

Sculpin Installation:

Install Sculpin using the command line (requires a modern PHP version, 5.6 recommended):

<code class="language-bash">wget https://download.sculpin.io/sculpin.phar
chmod +x sculpin.phar
sudo mv sculpin.phar /usr/local/bin/sculpin</code>

Alternatively, place sculpin.phar in a convenient directory and execute it directly.

Blog Creation:

  1. Clone the Sculpin Blog Skeleton: git clone https://github.com/sculpin/sculpin-blog-skeleton.git myblog
  2. Navigate to the directory: cd myblog
  3. Install dependencies: sculpin install
  4. Generate and serve the site (for development): sculpin generate --watch --server (access at http://localhost:8000)
  5. Generate a production-ready site: sculpin generate --env prod (output in output_prod)

Sculpin Extended: Customizing Your Static Site Blog

Configuration:

Sculpin's configuration is managed through sculpin_site.yml (global settings, Disqus username, etc.) and sculpin_kernel.yml (theme, permalinks).

Blogging with Sculpin:

Sculpin uses .md files for blog posts. A helpful touch.php script simplifies post creation:

<code class="language-php"><?php
$date = date('Y-m-d');
if(!empty($argv[2])){ $date = $argv[2]; }
$file = 'source/_posts/' . $date . '-' . str_replace('_', '-', $argv[1]) . '.md';
$title = ucwords(str_replace('_', ' ', $argv[1]));
$handle = fopen($file, 'w');
$data = "---\ntitle: {$title}\ntags: []\ncategories: []\n\n---\n\n";
fwrite($handle, $data);
?></code>

Use it like this: php touch.php my-new-post 2024-10-27

Site Customization:

The article details customizing the homepage (source/index.html), leveraging Twig templating and the pagination generator for displaying posts. It also covers creating individual post pages (_views/post.html) and adding Disqus comments. Custom CSS is used to style the blog.

Sculpin Extended: Customizing Your Static Site Blog

Deployment to GitHub Pages:

  1. Generate the production site (sculpin generate --env prod).
  2. Initialize a Git repository in output_prod.
  3. Commit and push to your your_username.github.io repository.

Conclusion:

Sculpin offers a powerful and developer-friendly approach to static site blogging for PHP developers. The provided GitHub repository contains the code examples. The FAQ section addresses common questions about Sculpin and blog customization.

The above is the detailed content of Sculpin Extended: Customizing Your Static Site Blog. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn