chriskyfung / amp-affiliately-jekyll-theme

An AMP-Ready Jekyll Blog Theme
https://chriskyfung.github.io/amp-affiliately-jekyll-theme/
MIT License
19 stars 12 forks source link

🩹 Fix(build): Jekyll Archives plugin generates duplicate files in _site directory #50

Closed chriskyfung closed 9 months ago

chriskyfung commented 9 months ago

Description

When using the Jekyll Archives plugin to generate archive pages for categories and tags, it creates multiple files with the same name in the _site directory, causing a conflict. For example, the following destination is shared by two files:

./amp-affiliately-jekyll-theme/_site/category/doc/index.html
 - category/doc/index.html
 - category/doc/index.html

This results in unexpected contents in the written file, and may affect the functionality of the site.

Steps to reproduce

  1. Install the Jekyll Archives plugin according to the documentation.
  2. Run bundle exec jekyll serve or jekyll serve to build the site locally.
  3. Observe the conflict warning in the terminal output.
  4. Check the _site directory and find the duplicate files.

Expected behavior

The Jekyll Archives plugin should generate only one file per destination, and avoid creating duplicate files in the _site directory.

Possible solutions

Upon inspection, it was found that the source directory contains a duplicate file that matches the archive path. The file is configured to provide the URL redirection from category/guide/ to category/to/.

To resolve this issue, we may rename the category/doc to category/guide and set the redirection using the front matter redirect_to instead of redirect_from.

Additional information