Pular para o conteúdo

HTML Fixer

The fixer tool in site/fixer/ converts standalone .html files into folder-based structures with index.html inside.

Problem

Some HTML files are structured as:

public/calculadoras/calculadora.html

But they should be:

public/calculadoras/calculadora/index.html

Solution

For each .html file (except index.html):

  1. Creates a folder with the same name (without .html)
  2. Moves the file inside as index.html

Usage

Using Make

Terminal window
# Preview changes
make fix-posts-dry
# Apply fixes
make fix-posts

Using Binary

Terminal window
# Build
go build -o fixer/fixposts ./fixer/cmd/fixposts
# Run on public directory
./fixer/fixposts -dir public
# Dry run
./fixer/fixposts -dir public -dry-run
# Verbose
./fixer/fixposts -dir public -v

Safety

  • Files already named index.html are skipped
  • If target folder exists, file is skipped
  • Use -dry-run first to preview