This is a personal blog project built with Go, designed to showcase posts, articles, and other content. The blog uses Strapi, a headless CMS, for content management and integrates various features such as RSS feeds, a newsletter subscription, and a responsive design.
- Dynamic Content Management: Content is fetched from Strapi, allowing easy updates and management.
- Responsive Design: The blog is fully responsive and works seamlessly across devices.
- RSS Feed: Automatically generates an RSS feed for posts.
- Newsletter Subscription: Allows users to subscribe to a newsletter.
- Search Functionality: Users can search for posts using a search bar.
- Table of Contents: Automatically generates a table of contents for posts.
- Static Assets: Includes static assets such as images, styles, and scripts.
.
├── cmd/
│ └── myBlog/
│ └── main.go # Entry point of the application
├── dummyData/
│ └── dummyPosts.json # Dummy data for local development
├── internal/
│ ├── config/
│ │ └── config.go # Configuration management
│ ├── handlers/
│ │ ├── about.go # Handler for the About page
│ │ ├── home.go # Handler for the Home page
│ │ ├── posts.go # Handler for Posts
│ │ ├── rss.go # Handler for RSS feed
│ │ └── search.go # Handler for Search functionality
│ ├── models/
│ │ └── posts.go # Data model for blog posts
│ └── utils/
│ ├── logger.go # Logging utilities
│ ├── template.go # Template rendering utilities
│ └── timer.go # Timer utility for periodic tasks
├── static/
│ ├── img/ # Static images
│ ├── script/ # JavaScript files
│ │ ├── main.js # Main script for the blog
│ │ └── post.js # Script for post-specific functionality
│ └── style/
│ └── styles.css # CSS styles
├── templates/
│ ├── about.html # Template for the About page
│ ├── home.html # Template for the Home page
│ └── post.html # Template for individual posts
├── logs/
│ └── logs.txt # Log file for application events
├── .env # Environment variables
├── go.mod # Go module file
└── go.sum # Go dependencies checksum
- Go: Version 1.23.2 or higher.
- Strapi: A running instance of Strapi for content management.
- Node.js: For managing Strapi (if running locally).
- Environment Variables: Configure the
.envfile with the following variables:API_ADDRESS: The base URL of the Strapi instance.API_KEY: The API key for accessing Strapi.DEBUG: Set toTRUEfor development mode.
-
Clone the repository:
git clone https://github.com/your-username/personal-blog.git cd personal-blog -
Install dependencies:
go mod tidy
-
Set up the .env file:
cp .env.example .env # Update the .env file with your Strapi API details -
Run the application:
go run cmd/myBlog/main.go
-
Replace the default icon: Replace the file at
static/img/icon.svgwith your own icon to ensure it appears in the page title and navbar.
- Home Page: Accessible at home, displays a list of blog posts.
- Post Page: Accessible at
/posts/{UUID}, displays individual posts. - About Page: Accessible at
/about, displays information about the blog owner. - RSS Feed: Accessible at
/rss.xml, provides an RSS feed of the blog posts. - Newsletter Registration: Accessible via the home page modal.
The application fetches posts from Strapi using the FetchPosts function. In development mode (DEBUG=TRUE), it uses dummy data from dummyPosts.json.
Logs are stored in logs.txt. The application uses utils.InfoLogger and utils.ErrorLogger for logging.
HTML templates are located in the templates directory. They use Go's html/template package for rendering.
-
Build the application:
go build -o blog cmd/myBlog/main.go
-
Deploy the binary and static files to your server.
-
Ensure the .env file is configured correctly on the server.
-
Start the application:
./blog
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Strapi for content management.
- Go for powering the backend.
- Bootstrap for responsive design.
- Font Awesome for icons.