loading...

I turned my website into a template, mostly by git tricks

patarapolw profile image Pacharapol Withayasakpunt Updated on ・2 min read

This was created by

  • Move personalized information from every folders to some very specific folders
/blog/**/*.md # Any deep nesting is possible
/media/
/theme.yml
  • Separate to two repos, of theme, and of content
# Shared commands
brew install git-filter-repo # https://github.com/newren/git-filter-repo/blob/main/INSTALL.md
# Content repo
git remote add upstream <GIT_UPSTREAM_URL>
git fetch upstream
git pull upstream master
git remote remove upstream
git filter-repo --path 'blog/**/*.md' --path 'media/' --path theme.yml --force # and other related content folders in the past
git push origin master
# Theme repo
git remote add upstream <GIT_UPSTREAM_URL>
git fetch upstream
git pull upstream master
git remote remove upstream
git filter-repo --invert-paths --path 'blog/**/*.md' --path 'media/' --path theme.yml --force # and other related content folders in the past
echo '/content/' >> .gitignore
git push origin master
  • Then, add environmental variables to Netlify as needed. After, if you working repo git is connected to Netlify
# Working repo
git remote add upstream <GIT_THEME_URL>
git fetch upstream
git switch -c dev upstream/master
git clone <GIT_CONTENT_URL> content
git push origin dev
git branch -D master
git checkout master
git push -f origin master

I also summarized this on GitHub's wiki.

GitHub logo patarapolw / nuxt-blog-template

Nuxt.js blog template, with working version at https://www.polv.cc

nuxt-blog-template

Commitizen friendly

Features

  • Nuxt.js with full TypeScript (nuxt-ts)
  • Markdown-it extended with Pug and LiquidJS
  • CSS is allowed
  • Images in markdown are optimized as WebP format
  • Separated content and theme. Either or both can be private.
  • Searchable via lunr.js
  • Easy to deploy on Netlify

Initialization

  • There are two ways, forking, and using upstream
  • Add your contents to /content/, or process.env.CONTENT_PATH
CONTENT_PATH=<PATH_TO_YOUR_CONTENT>

content folder structure

/post/**/*.md
/media/
/theme.yml

/theme.yml structure

Since it is linted and typed with zod, it is best to read the schema here.

Markdown structures

It is Markdown with YAML Frontmatter.

---
title: string
date: string | undefined (parsable by dayjs)
image: string | undefined
tag: array of string | undefined
(Additional keys can be added, but it won't be parsed)
---
Put your excerpt here
<!-- excerpt -->
Put your remaining content here

You might…

Of course, this is used in a real website -- https://www.polv.cc and the lighthouse score (https://web.dev/measure/) is quite commendable, I think; although there are indeed rooms to improve.

Lighthouse score

Posted on by:

patarapolw profile

Pacharapol Withayasakpunt

@patarapolw

Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning DevOps, though.

Discussion

markdown guide