构建后不需要的 _posts 结构

Unwanted _posts structure after build

我的存储库中有当前结构:

./_posts/2018-07-01-A-Post.md
./_posts/2018-07-01-Another-Post.md
./modules/A_Module/_posts/2018-07-01-A-Third-Post.md

上面的所有文件都有这个前言:

---
layout:     article
permalink:  /article/:categories/:title
title:      A Post
date:       2018-07-01 12:00:00
categories: Announcement
thumbnail:  
author:     lipkau
tags:
 - Release
---

./modules/A_Module 是一个加载了 .gitmodules 的子模块,"A Third Post" 在该存储库中维护。

我想要的是所有 post 都以完全相同的方式显示。但事实证明我错了。这是 ./_site:

中的结果
./_site/article/announcement/A-Post.html
./_site/article/announcement/Another-Post.html           <--- all good so far
./_site/modules/A_Module/announcement/A-Thrid-Post.html  <--- why did this happen?

这是我的 编辑 _config.yml:

# Website settings
title: AtlassianPS
description: A PowerShell community for Atlassian products
keywords: Atlassian,AtlassianPS,jira,confluence,bitbucket,hipchat,jiraps,confluenceps,bitbucketps,hipchatps,github,gh-pages
baseurl: ""
url: "https://atlassianps.org"

# analytics
## google analytics
ga: UA-XXXXXXXX-1

# Build settings
encoding: utf-8

# other settings
excerpt_separator: <!--more-->

markdown: kramdown

kramdown:
  input: GFM
  hard_wrap: false
  syntax_highlighter_opts:
    disable: true

这是我的 .gitmodules:

[submodule "modules/JiraPS"]
    path = modules/JiraPS
    url = https://github.com/AtlassianPS/JiraPS.git
    branch = master

我必须如何更改文件,以便我可以在不同的存储库中维护一个 post,但仍具有与其他 post 相同的结构? 我希望第三个 post 出现,但不是 https://.../article/modules/A_Module/announcement/A-Third-Post 而是 https://.../article/announcement/A-Third-Post

感谢您的帮助

更新的答案:

最快和最简单的解决方法是在您的文档的 front-matter 中对永久链接进行硬编码。您已经为每个文档指定了一个永久链接,因此这不应该成为障碍。然而,由于 modules 是一个自定义集合,你不应该使用像 : article 这样的变量,你应该像这样硬编码它:

permalink: /article/announcement/A-post

尽管您可以在永久链接中使用 : categories 变量,但您仍然不应该使用它,因为它可以是数组而不总是字符串。

或(如果不使用 URL 重写:

permalink: /article/announcement/A-post.html