pluja / blogo

A lightweight blogging engine that backs itself up to Nostr!
https://blogo.site
MIT License
120 stars 10 forks source link
blog blog-engine blog-platform blogging go golang nostr nostr-protocol

🎈 Blogo

Blogo is a light and easy blogging engine. No complicated extras, just a straightforward blog.

Now, here's the twist: Blogo can also publish your posts to Nostr for backing them up and getting even more reach. Lift your ideas higher!

Some blogs using Blogo

Features

Self-hosting using Docker Compose

The easiest way to self-host Blogo is by using Docker.

  1. Get the docker-compose.yml:
services:
  blogo:
    image: pluja/blogo:latest
    container_name: blogo
    restart: unless-stopped
    volumes:
      - ./articles:/app/articles
    ports:
      - "127.0.0.1:3000:3000"
    environment:
      # CONFIG
      BLOGO_TITLE: Blogo
      BLOGO_DESCRIPTION: A blog built with Blogo!
      BLOGO_KEYWORDS: blog,open source
      BLOGO_URL: http://localhost:3000
      #BLOGO_ANALYTICS: '<script defer src="https://my.analytics.site/script.js"></script>'
      TIMEZONE: UTC

      # NOSTR CONFIG
      PUBLISH_TO_NOSTR: false
      #NOSTR_NSEC: ""
      #NOSTR_RELAYS: "wss://nostr-pub.wellorder.net,wss://relay.damus.io,wss://relay.nostr.band"
  1. Edit the docker-compose.yml file to fit your needs.

  2. Run blogo:

docker compose up -d

Blogo is now available at http://localhost:3000. You can now create your first article.

Usage

Using Blogo is pretty simple. Once you have blogo running, you can create new articles by just running blogo -new my-post-slug, where my-post-slug is the slug of the post (used in the url). This will create a new template in the articles folder. Edit that file with your favorite text editor. Once done, save it and Blogo will take care of the rest (yes, it auto-reloads).

If you're on docker, you can run docker exec -it blogo blogo -new my-post-slug to create a new post.

Metadata fields

Blogo uses YAML metadata to get the post info. The metadata is located at the top of the file, between --- and ---.

Here's a list of the available metadata fields:

About page

To create an about page, just create a file called about.md in the articles folder. Blogo will automatically detect it and create a link to it in the navbar.

Static Content

To add your own static content, you can just bind-mount any folder to /app/static/your-folder.

For example if you are using docker compose, you can add:

volumes:
    - ./img:/app/static/img

Then you can just use /static/img/your-image.jpg in the markdown to add an image.

The /app/static folder contains the css styles needed for styling Blogo. For this, it is recommended to always create subfolders with bind mounts inside.

Publish to Nostr

If you set the PUBLISH_TO_NOSTR variable in the docker-compose.yml file to true, Blogo will publish your posts to Nostr. By default, Blogo will generate an ephemeral key (changes on every restart) and use a default relay list.

You can change either of these defaults by setting any of these variables in the docker-compose.yml file:

You can avoid publishing a particular post to Nostr by setting the NostrUrl metadata field in the post to false or 0.

Posts are published to Nostr as Long-Form events following the definition in NIP-33.

Add analytics

You can add analytics to your blog by setting the BLOGO_ANALYTICS variable in the docker-compose.yml file to your analytics script. Blogo will automatically add it to the bottom of the page. Make sure to put it all in a single line!

BLOGO_ANALYTICS='<script defer src="https://my.analytics.site/script.js"></script>'

Customization

You can customize the look and feel of your blog by editing the templates and CSS.

Templates

The templates are located in the templates folder:

Styles

The templates are written in Golang Templates, and the CSS is written in TailwindCSS and pure CSS. Feel free to tweak them to your liking.

The CSS is located in the static/css folder.

The main content makes use of TailwindCSS classes, so you can just tweak that to your liking. Note: You will need to rebuild the TailwindCSS using npx for new classes to apply.

The rendered Markdown is styled with pure CSS. You can tweak that in the static/css/markdown.css file. All markdwon is wrapped inside a div with the markdown id, so you can use that to style it.

Adding more stylesheets

You can easily add custom stylesheets to any page. Place the stylesheet into the static/css/ folder. Then, just use the extra block from the template to link them. (take a look at the post.html template and look for the extra block to see how it's done).