How to show posts of my kmt theme on demo but not on others' websites

ยท ยท 353 words ยท 2 minute read

I want to create documentation and tutorials about my Hugo theme KMT, but I want to simplify my setup by adding them inside the theme itself. But if I added the posts in kmt theme, they’ll show up on all websites that use the Kmt theme!

Another project for demo ๐Ÿ”—

I can use another instance/project that uses kmt theme, and add posts in it, and deploy it as the kmt theme demo. But.. but this is more complicated.. I think.

Published drafts (read the update below) ๐Ÿ”—

There is a simpler strategy I used. Just let the deployed version of my kmt theme demo include draft posts. Here are the steps.

All posts of the kmt theme demo are drafts ๐Ÿ”—

I just made all posts as drafts in each post frontmatter.

title = 'some title'
date = 2024-01-15T20:49:30+02:00
- draft = false
+ draft = false

Include draft posts in the generated website before deployment ๐Ÿ”—

I use Netlify to demo my kmt theme, so I just need to include -D argument in all Hugo commands in netlify.toml like this.

    publish = "public"
-    command = "hugo --gc --minify"
+    command = "hugo -D --gc --minify"

    HUGO_VERSION = "0.120.4"
    HUGO_ENV = "production"

-    command = "hugo --gc --minify --enableGitInfo"
+    command = "hugo -D --gc --minify --enableGitInfo"

    HUGO_VERSION = "0.120.4"
    HUGO_ENV = "production"

-    command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
+    command = "hugo -D --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"

    HUGO_VERSION = "0.120.4"

-    command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
+    command = "hugo -D --gc --minify -b $DEPLOY_PRIME_URL"

    HUGO_VERSION = "0.120.4"


If you are using another hosting service such as cloudflare pages or github pages, set the deploy command to include -D argument and you’ll be fine.

Update : 24 Jan 2024 ๐Ÿ”—

I decided to use a separated project as a demo. But it will not be a new project. I will use my own website as the demo of the theme and I will publish the documentation there too.