Skip to content

thrama/hugo-links-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hugo Links Bot

Telegram bot that automatically adds links to the content/links/_index.md file of a Hugo site hosted on GitHub Pages.


How it works

  1. You send a message with a URL to the bot on Telegram
  2. The bot fetches the page title automatically
  3. A formatted entry is prepended to content/links/_index.md via the GitHub API
  4. The GitHub Actions workflow triggers and deploys the updated site within ~2 minutes

Message Format

The bot parses three components from your message: URL, tags, and comment.

https://example.com #tag1 #tag2 Optional comment here
Component Required Format Example
URL ✅ Yes Must start with http:// or https:// https://martinfowler.com/articles/data-mesh.html
Tags ❌ No Words prefixed with # #datamesh #architecture
Comment ❌ No Any text that is not a URL or tag Interesting take on data ownership

Examples

URL only:

https://martinfowler.com/articles/data-mesh.html

URL with tags:

https://martinfowler.com/articles/data-mesh.html #datamesh #architecture

URL with tags and comment:

https://martinfowler.com/articles/data-mesh.html #datamesh #architecture Interesting take on data ownership

Order does not matter — tags and comment can appear before or after the URL:

#ai #governance https://example.com Great overview of AI governance frameworks

Output in the markdown file

Each message produces an entry like this:

- [Page Title](https://example.com) — Great overview of AI governance frameworks
  `#ai` `#governance`
  `2026-05-07`

If the page title cannot be fetched (e.g. the site blocks scraping), the domain name is used as fallback:

- [example.com](https://example.com)
  `2026-05-07`

Environment Variables

Variable Description
TELEGRAM_TOKEN Token from @BotFather
GITHUB_TOKEN GitHub Fine-grained Personal Access Token (Contents: read/write)
GITHUB_REPO Repository in owner/repo format (default: thrama/thrama.github.io)
ALLOWED_USER_ID Your Telegram numeric user ID (see below)

Deploy on Railway

  1. Create a new private GitHub repo (e.g. hugo-links-bot) and push these 3 files: bot.py, requirements.txt, Procfile
  2. Go to railway.app → login with GitHub
  3. New Project → Deploy from GitHub repo → select hugo-links-bot
  4. Go to the service → tab Variables → add the 4 environment variables above
  5. Railway deploys automatically after saving the variables

Get your Telegram User ID

Open Telegram, search @RawDataBot, send any message. It replies with a JSON — your ID is the value of message.from.id.


Get a Telegram Bot Token

  1. Open Telegram → search @BotFather
  2. Send /newbot
  3. Follow the prompts to choose a name and username
  4. BotFather replies with your token — copy the full string including the numeric prefix (e.g. 7123456789:AAF...)

Verify the token is valid:

https://api.telegram.org/botYOUR_TOKEN/getMe

Should return "ok": true.


Files

File Description
bot.py Main bot script
requirements.txt Python dependencies
Procfile Railway worker definition

About

Telegram bot that automatically adds links to the content/links/_index.md file of a Hugo site hosted on GitHub Pages.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors