DEV Community

Fairywen
Fairywen

Posted on

How to schedule new blog posts

Some of you may be looking for a way to prepare Hugo-blog content, and post it automatically on a specific day without having any further action to do.

Here is a very simple way to handle this, using both Hugo and GitHub Action functionalities.

Step 1 : Hugo side

A Hugo-based blog content is basically a Markdown file, which contains at its beginning a front matter bloc (using yaml or toml syntax).

This front matter let us set several properties.

For example, here is one from a post of mine :

+++
title = "How to plan your blog posts in advance"
date = 2024-06-10
draft = false
tags = ["tuto","blogging"]
categories = ["tech"]
+++
Enter fullscreen mode Exit fullscreen mode

One can notice the presence of a date field, allowing not only to set up post's writing date, but will be used by Hugo while building the site.

Indeed, Hugo default behavior is to not build future contents.

That's exactly what we need here. Just write the desired publish date instead, and then build periodically the site !

Step 2 : GitHub side

GitHub Actions manages build of the site through a .github\workflows\hugo.yml file, created by GitHub while the workflow is configured the first time (note by the way that it looks like a Jenkinsfile a lot).

My first usage was to build on every push on the main branch :

# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

# Deploying actions
Enter fullscreen mode Exit fullscreen mode

So I simply added a scheduled trigger (see documentation here) every friday morning.

Notice that time is UTC-based, and it is not possible for now to use timezone (see this discussion).

Let's add the scheduled trigger in hugo.yml file :

# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

  # Runs every friday at 5 o'clock AM UTC to publish "music friday" posts
  schedule:
    - cron: '00 05 * * 5'
Enter fullscreen mode Exit fullscreen mode

Here we are !

From now on, the site will be also build once a week to generate contents that was in the future.

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay