Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Personal blog using htmx and automated page generation from markdown files

NotificationsYou must be signed in to change notification settings

markbeep/htmx-blog

Repository files navigation

Playwright TestsDeploy DockerfileGo version

This is mypersonal blog. It started out as a simple project to practice usinghtmx to makeit an extremely lightweight and efficient website andtailwindcss for the styling.

One important requirement was that all my blog posts were to be written in markdown (in/content). It then turned out to bea bigger challenge to get the markdown file generation working than actually creating the blog. I first started out usingpandocto generate the markdown externally, but pandoc does some very weird styling and the syntax highlighting colors they support lookreally bad. I instead then opted forgoldmark which is also in use by thehugo.

Installation

To get the blog running locally you first needgo 1.21. You'll also needtempl which has three quick ways to install:

go install github.com/a-h/templ/cmd/templ@latest# install via gocurl -o https://github.com/a-h/templ/releases/download/v0.2.432/templ_Linux_x86_64.tar.gz&& chmod +x templ# install binarynix run github:a-h/templ# run using nix

Once templ and go is set, you can generate the template go files and then start the server:

templ generatego run.

Hot Reload

For the best developer experience I recommend gettingair which enables hot-reloading on save. Install air and run it:

go install github.com/cosmtrek/air@latestair

Styling

If you're working on the css or styling, it is recommended to also get thetailwindcss CLI tool and run it on the side to keep on updatingthemain.css stylesheet:

tailwindcss -i static/tw.css -o static/main.css --watch

Docker

It's also possible to start up the website usingDocker:

docker compose up --build

This will build and start up the website as well as run the playwright tests. If you're building for arm64, you'll need to modify the Dockerfile and swap outthe tailwindcss CLI tool installation for the arm64 version.

Testing

For extensive testing,Playwright is used. To make the install simpler, there's a Dockerfileine2e/Dockerfile.playwright. Build and run it from theroot directory.

docker build -t htmx-playwright -f e2e/Dockerfile.playwright.docker run --rm -it --network host htmx-playwright /bin/bash

Nix

With theflake.nix andflake.lock files you can set up local development with the exact same dependency versions.

nix develop# downloads all required dependenciesnix build .#htmx-blog # build the blognix run .#htmx-blog # build and run the blog locallynix run .#tailwindcss -- -i static/tw.css -o static/main.css --watch

Note: Tailwindcss still needs to be executed manually on the side to generate thestatic/main.css file

Creating Posts

Posts can be created by executing thepost.sh script. Simply execute the following:

./post.sh content/posts/name_of_post

About

Personal blog using htmx and automated page generation from markdown files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp