Home >Backend Development >PHP Tutorial >Sculpin Extended: Customizing Your Static Site Blog
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.
Key Benefits:
sculpin_site.yml
and sculpin_kernel.yml
.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:
git clone https://github.com/sculpin/sculpin-blog-skeleton.git myblog
cd myblog
sculpin install
sculpin generate --watch --server
(access at http://localhost:8000
)sculpin generate --env prod
(output in output_prod
)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.
Deployment to GitHub Pages:
sculpin generate --env prod
).output_prod
.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!