### Routes Mapping Example
Source: https://www.priority.vision/docs/thesis/getting-started-routes-setup
This example demonstrates how the routes.yaml file maps custom URL patterns to specific content listings within the Ghost theme. It defines how to display posts by tag and by author.
```yaml
# /tag/*/ - List of all posts with the tag
# /author/*/ - List of all posts by the author
```
--------------------------------
### Ghost Version Check Command
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
This command verifies the currently installed version of the Ghost CLI and the Ghost platform itself. Keeping Ghost updated is crucial for performance improvements and bug fixes.
```shell
# Confirm current Ghost version
ghost version
```
--------------------------------
### Install Theme Dependencies (npm)
Source: https://www.priority.vision/docs/thesis/advanced-editing-theme-code
Installs the necessary Node.js dependencies for your Ghost theme, typically defined in the `package.json` file. This is a prerequisite for running build commands.
```shell
npm install
```
--------------------------------
### Ghost Theme Deployment Workflow (YAML)
Source: https://www.priority.vision/docs/thesis/advanced-deploying-theme-with-github-actions
This GitHub Actions workflow automates the building and deployment of a Ghost theme. It checks out the code, sets up Node.js, installs dependencies, builds the theme for production, and then deploys it to a Ghost site using the TryGhost/action-deploy-theme action, requiring Admin API URL and Key as secrets.
```yaml
name: Deploy Ghost Theme
on:
workflow_dispatch: # Allows manual triggering
push:
branches:
- master
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build theme
run: npm run build:prod
- name: Deploy to Ghost
uses: TryGhost/action-deploy-theme@v1
with:
api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
```
--------------------------------
### Ghost Production Caching Configuration
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
Sets up frontend caching parameters for a Ghost installation in a production environment. This JSON configuration helps manage how long frontend resources are cached, impacting performance and load times.
```json
// config.production.json
{
"caching": {
"frontend": {
"maxAge": 600
}
}
}
```
--------------------------------
### MySQL Server Optimization (my.cnf)
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
Optimizes MySQL server performance by adjusting key configuration parameters. These settings are crucial for handling database operations efficiently, especially for large Ghost installations. Adjust values based on available server resources.
```sql
# my.cnf - adjust values based on available server resources
[mysqld]
innodb_buffer_pool_size = 512M # Scale with available RAM
innodb_log_file_size = 128M
max_connections = 100
query_cache_size = 64M
tmp_table_size = 32M
max_heap_table_size = 32M
```
--------------------------------
### Self-Host Custom Fonts - CSS @font-face Declarations
Source: https://www.priority.vision/docs/thesis/essentials-typography
This CSS code demonstrates how to declare self-hosted custom fonts using the `@font-face` rule within a Ghost theme's `default.hbs` file. It includes examples for regular and bold weights of 'YourCustomFont' using WOFF2 and WOFF formats, setting CSS variables for body and heading fonts. Ensure font files are correctly placed in the theme's assets.
```css
@font-face {
font-family: 'YourCustomFont';
src: url('{{asset "fonts/your-custom-font.woff2"}}') format('woff2'),
url('{{asset "fonts/your-custom-font.woff"}}') format('woff');
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'YourCustomFont';
src: url('{{asset "fonts/your-custom-font-bold.woff2"}}') format('woff2'),
url('{{asset "fonts/your-custom-font-bold.woff"}}') format('woff');
font-weight: 700;
font-style: normal;
font-display: swap;
}
/* Add more @font-face declarations for additional font weights and styles */
:root {
--gh-font-body: 'YourCustomFont', sans-serif;
--gh-font-heading: 'YourCustomFont', sans-serif;
}
```
--------------------------------
### Create Simple Markdown Table
Source: https://www.priority.vision/docs/thesis/essentials-tables
Demonstrates how to create a basic table using Markdown syntax. This method is straightforward and widely supported.
```markdown
| Header 1 | Header 2 | Header 3 |
|----------|----------|----------|
| Row 1 | Data 1 | Data 2 |
| Row 2 | Data 3 | Data 4 |
```
--------------------------------
### Create Responsive Table with HTML Wrapper
Source: https://www.priority.vision/docs/thesis/essentials-tables
Shows how to make a Markdown table responsive by wrapping it in a `
` element with the class `responsive-table`. This ensures tables adapt to different screen sizes.
```html
| Header 1 | Header 2 | Header 3 |
|----------|----------|----------|
| Row 1 | Data 1 | Data 2 |
| Row 2 | Data 3 | Data 4 |
```
--------------------------------
### Add Custom Navigation Icon with SVG (JavaScript)
Source: https://www.priority.vision/docs/thesis/essentials-navigation
This snippet demonstrates how to add a custom SVG icon to a navigation item labeled 'Cart' using the `addNavIcon` API provided by the Thesis theme. It requires JavaScript execution via Code Injection.
```javascript
window.pvs?.addNavIcon?.(
'Cart',
''
);
```
--------------------------------
### Ghost CLI Update and Migration Commands
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
These commands update the Ghost CLI and the Ghost platform to the latest version, followed by executing database migrations. Updates often include performance enhancements and necessary database schema changes.
```shell
# Update Ghost CLI and platform
npm update -g ghost-cli
ghost update
# Execute database migrations
ghost migrate
```
--------------------------------
### Add Android Social Link with SVG Icon (JavaScript)
Source: https://www.priority.vision/docs/thesis/essentials-social-links
Provides a specific example of adding the Android social link using the `addSocialLink` API. It includes the Android URL, the text 'Android', and the corresponding SVG icon path. This is useful for integrating platform-specific links.
```javascript
window.pvs?.addSocialLink?.(
'https://www.android.com/',
'Android',
'
);
```
--------------------------------
### Docker Compose Resource Allocation for Ghost and Database
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
This Docker Compose configuration snippet shows how to allocate resources (memory and CPUs) to the Ghost and database services. Adjusting these limits can resolve performance bottlenecks due to resource constraints.
```yaml
# docker-compose.yml
services:
ghost:
image: ghost:latest
deploy:
resources:
limits:
memory: 1G # Increase from default allocation
cpus: '1.0'
reservations:
memory: 512M
cpus: '0.5'
database:
image: mysql:8.0
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
```
--------------------------------
### Ghost Database Connection Pool Configuration
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
This configuration file defines the connection pool settings for the Ghost database. Tuning parameters like `min`, `max`, and timeouts can significantly improve database performance and stability.
```json
// config.production.json
{
"database": {
"client": "mysql",
"connection": {
"pool": {
"min": 5,
"max": 20,
"acquireTimeoutMillis": 60000,
"createTimeoutMillis": 30000,
"destroyTimeoutMillis": 5000,
"idleTimeoutMillis": 30000,
"reapIntervalMillis": 1000,
"createRetryIntervalMillis": 200
}
}
}
}
```
--------------------------------
### Configure Posts Per Page in package.json
Source: https://www.priority.vision/docs/thesis/advanced-ghost-config
Sets the number of posts displayed on blog list pages before pagination is applied. This configuration is managed within the 'package.json' file.
```json
"config": {
...
"posts_per_page": 10,
...
}
```
--------------------------------
### Ghost Production Server and Database Configuration
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
Configures the Ghost server's host and port, along with database connection timeout settings for production environments. This JSON file is essential for defining the operational parameters of a Ghost instance.
```json
// config.production.json
{
"server": {
"host": "0.0.0.0",
"port": 2368
},
"database": {
"connection": {
"timeout": 60000,
"acquireTimeout": 60000
}
}
}
```
--------------------------------
### Docker Monitoring and Logging Commands
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
These shell commands help monitor the resource usage of your Ghost Docker container and review its application logs for performance issues. Ensure the container name is correctly specified.
```shell
# Monitor real-time resource usage
docker stats your-ghost-container
# Review Ghost application logs
docker logs your-ghost-container
```
--------------------------------
### Initialize Code Highlight - Basic
Source: https://www.priority.vision/docs/thesis/custom-code-syntax-highlight
Initializes code syntax highlighting for all code cards using the Thesis theme's Shiki integration. This basic snippet enables default highlighting without additional features.
```javascript
window.pvs?.initCodeHighlight?.();
```
--------------------------------
### Ghost Handlebars for Advanced Sorting
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
These Handlebars helpers demonstrate sorting tags and authors by their post counts in descending order. This can be computationally expensive for the database, particularly with many entries.
```handlebars
{{#get "authors" order="count.posts DESC"}}
{{#get "tags" filter="visibility:public" order="count.posts DESC"}}
```
--------------------------------
### Ghost Theme Build Commands (npm)
Source: https://www.priority.vision/docs/thesis/advanced-editing-theme-code
Provides common npm commands for managing a Ghost theme's build process. These commands are used for development (watching for changes), production builds, and testing.
```shell
npm run dev
```
```shell
npm run build
```
```shell
npm run build:prod
```
```shell
npm run test
```
--------------------------------
### Ghost Handlebars for Tag and Author Post Counts
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
These Handlebars helpers retrieve tags and authors, including their associated post counts, which can be resource-intensive on large sites. Ensure server resources are adequate to prevent timeouts.
```handlebars
{{#get "tags" include="count.posts"}}
{{#get "authors" include="count.posts"}}
```
--------------------------------
### Initialize Code Highlight - Advanced Options
Source: https://www.priority.vision/docs/thesis/custom-code-syntax-highlight
Initializes code syntax highlighting with advanced features including a clipboard button, line numbers, and language badges. It also allows customization of light and dark themes.
```javascript
window.pvs?.initCodeHighlight?.({
clipboardButton: true,
lineNumbers: true,
languageBadge: true,
themes: {
light: 'github-light',
dark: 'github-dark',
},
});
```
--------------------------------
### HTML Contact Form for Ghost Blog
Source: https://www.priority.vision/docs/thesis/page-contact
This HTML code creates a basic contact form with fields for name, email, and message. It requires an 'action' attribute pointing to a form handling service's endpoint URL and uses the POST method. The 'target="_blank"' attribute ensures the form submission opens in a new tab.
```html
```
--------------------------------
### MySQL Table Optimization and Index Verification
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
These SQL commands optimize database tables for better performance and verify the existence of essential indexes. Creating or ensuring indexes on frequently queried columns like 'featured', 'status', and 'visibility' can drastically speed up queries.
```sql
-- Optimize database tables for improved performance
OPTIMIZE TABLE posts, tags, authors, posts_tags, posts_authors;
-- Verify essential indexes exist
SHOW INDEX FROM posts WHERE Column_name = 'featured';
SHOW INDEX FROM posts WHERE Column_name = 'status';
SHOW INDEX FROM posts WHERE Column_name = 'visibility';
-- Create missing indexes if necessary
CREATE INDEX idx_posts_featured ON posts(featured);
CREATE INDEX idx_posts_status ON posts(status);
```
--------------------------------
### Ghost Handlebars for Featured Content Filtering
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
This Handlebars helper retrieves posts specifically marked as 'featured'. Such filtering requires efficient database queries, especially with a large number of posts.
```handlebars
{{#get "posts" filter="featured:true"}}
```
--------------------------------
### Trigger Workflow on Release (YAML)
Source: https://www.priority.vision/docs/thesis/advanced-deploying-theme-with-github-actions
This YAML snippet shows how to configure a GitHub Actions workflow to trigger automatically when a new release is published in the repository. It specifies the 'release' event and the 'published' type.
```yaml
on:
release:
types: [published]
```
--------------------------------
### MySQL Process List and Slow Query Log Check
Source: https://www.priority.vision/docs/thesis/troubleshooting-slow-loading-and-failed-content-queries
These MySQL commands help diagnose database performance by showing active processes and checking the status of the slow query log. Analyzing slow queries can pinpoint inefficient database operations.
```sql
# Monitor active MySQL processes
mysql -e "SHOW PROCESSLIST;"
# Check slow query logging status
mysql -e "SHOW VARIABLES LIKE 'slow_query_log';"
```
--------------------------------
### Initialize Ads After AJAX Navigation
Source: https://www.priority.vision/docs/thesis/custom-ads-with-ajax
JavaScript code to initialize AdSense ads after AJAX page transitions. It listens for 'ready' and 'pvs.navigation.content-rendered' events and pushes the ad initialization if an ad unit is present.
```javascript
```
--------------------------------
### Trigger Workflow on Specific File Changes (YAML)
Source: https://www.priority.vision/docs/thesis/advanced-deploying-theme-with-github-actions
This YAML snippet demonstrates how to configure a GitHub Actions workflow to trigger only when specific files or directories within the repository are modified. It targets the 'main' branch and includes changes in 'assets' directory, '.hbs' files, and 'package.json'.
```yaml
on:
push:
branches:
- main
paths:
- 'assets/**'
- '*.hbs'
- 'package.json'
```
--------------------------------
### Configure Image Sizes in package.json
Source: https://www.priority.vision/docs/thesis/advanced-ghost-config
Defines responsive image sizes for a Ghost theme. These sizes are used to generate image variants upon upload via Ghost Admin. The configuration resides in the 'image_sizes' property within 'package.json'.
```json
"config": {
...
"image_sizes": {
"xxs": {
"width": 32
},
"xs": {
"width": 60
},
"s": {
"width": 200
},
"m": {
"width": 540
},
"l": {
"width": 880
},
"xl": {
"width": 1200
},
"xxl": {
"width": 1600
}
},
...
}
```
--------------------------------
### Add Bluesky Social Link (JavaScript)
Source: https://www.priority.vision/docs/thesis/essentials-social-links
Adds a social link for Bluesky to the project. It uses the `addSocialLink` function, providing the Bluesky app URL, the platform name 'Bluesky', and an SVG string for the Bluesky logo. No external dependencies are specified.
```javascript
window.pvs?.addSocialLink?.(
'https://bsky.app/',
'Bluesky',
'
```
--------------------------------
### Using `#video` Internal Tag for Featured Video
Source: https://www.priority.vision/docs/thesis/custom-post-featured-video
This snippet demonstrates how to use the `#video` internal tag within Ghost's post settings to designate a video as the featured video. This tag is not visible to readers and is used for theme features and integrations.
```text
Add the `#video` internal tag to **Tags** in the Post settings sidebar.
```
--------------------------------
### Restore Standard Ghost Signup Button with CSS
Source: https://www.priority.vision/docs/thesis/custom-portal-signup-button
This CSS code can be injected to restore the standard Ghost Sign Up button by overriding the existing style that hides it. It targets the iframe element within the ghost-portal-root.
```css
```