-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👌 IMPROVE: Updated the script a few places (i think, its been a long …
…few days)
- Loading branch information
1 parent
86d9156
commit 141cda3
Showing
7 changed files
with
381 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0: "Decentralized Publishing" | ||
1: "Customization" | ||
2: "Command-line" | ||
3: "Minify" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
content/posts/customizing-stattic.md → ...sts/command-line-arguments-for-stattic.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
content/posts/decentralizing-publishing-with-stattic.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--- | ||
title: Decentralizing Publishing with Stattic | ||
custom_url: decentralizing-publishing-with-stattic | ||
author: 1 | ||
date: 2024-10-01 | ||
categories: | ||
- 0 | ||
--- | ||
|
||
When control over content and website creation is increasingly centralized under unstable power, there's a growing need for tools that empower the community to publish independently. | ||
|
||
**Stattic** is an open source Python-based static site generator designed to simplify website creation and support the decentralization of publishing, giving the power back into the hands of the creator community where it belongs. | ||
|
||
## Key Features of Stattic | ||
|
||
The following list is in no particular order and will be changing as Stattic continues to grow with user needs in mind. | ||
|
||
### 1. Markdown Support | ||
|
||
Stattic uses Markdown for content creation, allowing you to write posts and pages in a straightforward and readable format. | ||
|
||
It employs the Mistune library to convert Markdown to HTML efficiently, supporting features like tables, task lists, and strikethrough text. | ||
|
||
### 2. Template Rendering with Jinja2 | ||
|
||
The generator utilizes Jinja2 templates for rendering HTML pages. | ||
|
||
This separation of content and presentation ensures flexibility and ease of maintenance, allowing you to customize the look and feel of your site without altering the content. | ||
|
||
### 3. Front Matter Metadata | ||
|
||
Each Markdown file can include front matter written in YAML. This metadata lets you define titles, authors, dates, categories, tags, and custom URLs, giving you control over how each page or post is presented. | ||
|
||
You can also add any custom metadata you'd like and then use it in the `templates` files, giving you unparalleled control over what content is displayed and in the way you best see fit. | ||
|
||
### 4. Automatic Image Handling | ||
|
||
Stattic processes images found in your Markdown content by downloading external images, converting them to the efficient WebP format using the Pillow library, and updating the content to reference the local image files. | ||
|
||
This improves site performance and ensures all assets are self-contained right out of the box. | ||
|
||
### 5. Google Fonts Integration | ||
|
||
The tool can download specified Google Fonts and save them locally. This reduces external dependencies and improves page load times. You can specify fonts like `Quicksand` or `Roboto` directly in the command-line options. | ||
|
||
### 6. Asset Management | ||
|
||
Stattic handles your CSS and JavaScript assets by copying them from a designated assets directory to the output directory. | ||
|
||
It offers an option to minify these assets using `csscompressor` and `rjsmin`, combining them into single minified files to optimize loading times. | ||
|
||
### 7. Logging and Error Handling | ||
|
||
Comprehensive logging is also built-in, recording the build process and any issues that arise. Logs are saved in a dedicated `logs` directory, aiding in troubleshooting and ensuring transparency. | ||
|
||
### 8. Command-Line Interface | ||
|
||
The script includes a command-line interface with options to: | ||
|
||
- Specify the output directory. | ||
- Set the number of posts per page. | ||
- Choose sorting preferences (date, title, author). | ||
- Define fonts to download. | ||
- Enable minification of assets. | ||
|
||
### 9. Support for Drafts | ||
|
||
Posts marked as drafts in their front matter are skipped during the build process, allowing you to work on content without immediately publishing it. | ||
|
||
Example: `draft: true` | ||
|
||
### 10. Pagination and Sorting | ||
|
||
Control how many posts appear on your index page and sort them by date, title, or author. This flexibility helps organize content to suit your audience's needs. | ||
|
||
**Example:** `--posts-per-page 5` | ||
|
||
### 11. Automatic Excerpts | ||
|
||
If an excerpt isn't provided in the front matter, Stattic automatically generates one from the first few words of the content, ensuring that summaries are always available. | ||
|
||
**Example:** `excerpt: "Custom text goes here"` | ||
|
||
### 12. Customizable Navigation | ||
|
||
Pages are loaded and sorted based on an 'order' value in their metadata, allowing you to customize the navigation structure of your site. | ||
|
||
In the front matter it's as simple as adding one word and one number. | ||
|
||
**Example:** `order: 5` | ||
|
||
## Getting Started with Stattic | ||
|
||
1. **Organize Your Content**: Place your Markdown files in the `content/posts` and `content/pages` directories. | ||
|
||
2. **Customize Templates**: Modify the templates in the `templates` directory using Jinja2 syntax to match your desired layout and design. | ||
|
||
3. **Run the Generator**: Use the command-line interface to build your site: | ||
|
||
`python3 stattic.py --output ~/my_website --posts-per-page 10 --sort-by date --fonts "Quicksand, Roboto" --minify` | ||
|
||
4. **Review the Output**: Your static site will be generated in the specified output directory, ready to be deployed to any static hosting service of your choice. | ||
|
||
## Decentralized Publishing for the People | ||
|
||
**Stattic** is a bullshit free tool that empowers you to publish content on your own terms. | ||
|
||
By simplifying static site generation and efficiently handling assets, it supports the movement toward decentralizing publishing. Whether you're a developer or a content creator, Stattic offers a minimalistic yet powerful solution for building your online presence. | ||
|
||
Feel free to contribute to the project on [GitHub](https://github.com/getstattic/stattic) or customize it to suit your specific needs. The project is covered under the MIT license which is also included in the GitHub repository. | ||
|
||
Together, we can promote a more decentralized and independent web 🤘 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
--- | ||
title: "Customizing Stattic: Front Matter Fields" | ||
custom_url: front-matter-fields-for-stattic | ||
author: 1 | ||
date: 2024-09-30 | ||
categories: | ||
- 1 | ||
--- | ||
|
||
### 1. **title** | ||
|
||
- **Description**: The title of your post or page. | ||
- **Type**: String | ||
- **Default**: `'Untitled'` | ||
- **Usage**: | ||
|
||
`title: "Your Post Title"` | ||
|
||
### 2. **date** | ||
|
||
- **Description**: The publication date of your post or page. | ||
- **Type**: String (formatted as `YYYY-MM-DDTHH:MM:SS`) | ||
- **Default**: Current date and time if not provided. | ||
- **Usage**: | ||
|
||
`date: "2023-10-15T10:00:00"` | ||
|
||
### 3. **author** | ||
|
||
- **Description**: The ID of the author of the post or page. | ||
- **Type**: Integer or String (should correspond to an ID in `authors.yml`) | ||
- **Default**: `'Unknown'` if not provided. | ||
- **Usage**: | ||
|
||
`author: 1 # Assuming '1' corresponds to an author in authors.yml` | ||
|
||
### 4. **categories** | ||
|
||
- **Description**: A list of category IDs that the post belongs to. | ||
- **Type**: List of Integers (IDs corresponding to entries in `categories.yml`) | ||
- **Default**: Empty list `[]` if not provided. | ||
- **Usage**: | ||
|
||
``` | ||
categories: | ||
- 2 | ||
- 5 | ||
``` | ||
|
||
### 5. **tags** | ||
|
||
- **Description**: A list of tag IDs associated with the post. | ||
- **Type**: List of Integers (IDs corresponding to entries in `tags.yml`) | ||
- **Default**: Empty list `[]` if not provided. | ||
- **Usage**: | ||
|
||
``` | ||
tags: | ||
- 3 | ||
- 7 | ||
``` | ||
|
||
### 6. **draft** | ||
|
||
- **Description**: Indicates whether the post is a draft. | ||
- **Type**: Boolean (`true` or `false`) | ||
- **Default**: `false` (the post will be published by default) | ||
- **Usage**: | ||
|
||
`draft: true # The post will be skipped during the build process` | ||
|
||
### 7. **template** | ||
|
||
- **Description**: Specifies a custom template to use for rendering. | ||
- **Type**: String (the name of the template part) | ||
- **Default**: `'post.html'` for posts, `'page.html'` for pages if not specified. | ||
- **Usage**: | ||
|
||
`template: "custom" # Will use 'post-custom.html' or 'page-custom.html'` | ||
|
||
### 8. **custom_url** | ||
|
||
- **Description**: Custom URL slug for the post or page. | ||
- **Type**: String | ||
- **Default**: The filename without the `.md` extension. | ||
- **Usage**: | ||
|
||
`custom_url: "my-custom-path"` | ||
|
||
### 9. **order** | ||
|
||
- **Description**: Determines the order of pages in navigation menus. | ||
- **Type**: Integer (lower numbers appear first) | ||
- **Default**: `100` if not specified. | ||
- **Usage**: | ||
|
||
`order: 1 # This page will appear before pages with higher 'order' values` | ||
|
||
### 10. **featured_image** | ||
|
||
- **Description**: URL of the featured image for the post or page. | ||
- **Type**: String (URL) | ||
- **Default**: `None` if not provided. | ||
- **Usage**: | ||
|
||
`featured_image: "https://example.com/images/featured.jpg"` | ||
|
||
### 11. **seo_title** | ||
|
||
- **Description**: Custom title for SEO purposes. | ||
- **Type**: String | ||
- **Default**: Uses the `title` field if not provided. | ||
- **Usage**: | ||
|
||
`seo_title: "Optimized SEO Title for Search Engines"` | ||
|
||
### 12. **keywords** | ||
|
||
- **Description**: SEO keywords for the post or page. | ||
- **Type**: String (comma-separated) | ||
- **Default**: Empty string `''` if not provided. | ||
- **Usage**: | ||
|
||
`keywords: "keyword1, keyword2, keyword3"` | ||
|
||
### 13. **description** | ||
|
||
- **Description**: SEO description for the post or page. | ||
- **Type**: String | ||
- **Default**: Empty string `''` if not provided. | ||
- **Usage**: | ||
|
||
`description: "A brief description of the content for SEO purposes."` | ||
|
||
### 14. **lang** | ||
|
||
- **Description**: Language code for the content. | ||
- **Type**: String (e.g., `'en'`, `'fr'`, `'es'`) | ||
- **Default**: `'en'` (English) if not specified. | ||
- **Usage**: | ||
|
||
`lang: "en"` | ||
|
||
### 15. **excerpt** | ||
|
||
- **Description**: Custom excerpt or summary of the post. | ||
- **Type**: String (supports Markdown) | ||
- **Default**: Automatically generated from the first 30 words of the content if not provided. | ||
- **Usage**: | ||
|
||
`excerpt: "This is a custom excerpt for the post."` | ||
|
||
* * * | ||
|
||
## Additional Details and Usage | ||
|
||
### **Categories and Tags** | ||
|
||
- **Definition Files**: Categories and tags are defined in `categories.yml` and `tags.yml`, respectively. | ||
- **Structure of YAML Files**: | ||
``` | ||
# categories.yml | ||
1: | ||
name: "Technology" | ||
2: | ||
name: "Science" | ||
# tags.yml | ||
1: | ||
name: "Python" | ||
2: | ||
name: "AI" | ||
``` | ||
- **Usage in Front Matter**: | ||
|
||
``` | ||
categories: | ||
- 1 # Refers to "Technology" | ||
- 2 # Refers to "Science" | ||
tags: | ||
- 1 # Refers to "Python" | ||
- 2 # Refers to "AI" | ||
``` | ||
|
||
### **Authors** | ||
|
||
- **Definition File**: Authors are defined in `authors.yml`. | ||
- **Structure**: | ||
``` | ||
# authors.yml | ||
1: "Jane Doe" | ||
2: "John Smith" | ||
``` | ||
|
||
- **Usage in Front Matter**: | ||
|
||
`author: 1 # Refers to "Jane Doe"` | ||
|
||
### **Custom Templates** | ||
|
||
- **Templates Directory**: Templates are stored in the `templates` directory. | ||
- **Template Naming**: | ||
- For posts: `post.html` or `post-{template}.html` | ||
- For pages: `page.html` or `page-{template}.html` | ||
- **Usage**: | ||
|
||
`template: "gallery" # Will use 'post-gallery.html' or 'page-gallery.html'` | ||
|
||
### **Example of Complete Front Matter** | ||
|
||
``` | ||
--- | ||
title: "Exploring the Stars" | ||
date: "2023-10-15T10:00:00" | ||
author: 2 | ||
categories: | ||
- 3 | ||
- 4 | ||
tags: | ||
- 5 | ||
- 6 | ||
draft: false | ||
template: "astronomy" | ||
custom_url: "exploring-the-stars" | ||
order: 2 | ||
featured_image: "https://example.com/images/stars.jpg" | ||
seo_title: "A Deep Dive into Astronomy" | ||
keywords: "astronomy, stars, space" | ||
description: "An in-depth exploration of the wonders of the universe." | ||
lang: "en" | ||
excerpt: "Join us as we journey through the cosmos, exploring the mysteries of the stars..." | ||
--- | ||
``` | ||
|
||
* * * | ||
|
||
## Notes on Usage | ||
|
||
- **Front Matter Format**: Ensure the front matter is enclosed at the top of your Markdown file between `---` lines. | ||
- **YAML Syntax**: Use proper YAML syntax to avoid parsing errors. Indentation and formatting are important. | ||
- **Optional Fields**: All fields are optional unless required by your site's design or functionality. The script provides default values where appropriate. | ||
- **Draft Posts**: | ||
- Set `draft: true` to exclude a post from the build. | ||
- Remove the `draft` field or set it to `false` when you're ready to publish. | ||
- **Custom URLs**: | ||
- Use `custom_url` to define a specific path for your post or page. | ||
- If not specified, the filename (without the `.md` extension) is used as the slug. | ||
|
||
* * * | ||
|
||
## Summary | ||
|
||
By utilizing these front matter fields, you can control various aspects of how your content is processed and displayed by the **Stattic** static site generator. | ||
|
||
This includes metadata for SEO, content organization through categories and tags, custom templates for different types of content, and more. | ||
|
||
Feel free to include any or all of these fields in the front matter of your Markdown files to customize your site's behavior and appearance according to your needs. |
Oops, something went wrong.