Use Discourse's search API to find new location of each page.
Done using this script:
```python
import yaml
import requests
import sys
import time
BASEURL = "https://forum.qubes-os.org"
def main(path):
with open(path) as f:
frontmatter = yaml.safe_load_all(f)
frontmatter = list(frontmatter)[0]
# rate limit of 20req/min...
time.sleep(3)
# https://docs.discourse.org/#tag/Search/operation/search
r = requests.get(f"{BASEURL}/search.json", params={
"q": f"{frontmatter['title']} #guides in:title"})
r.raise_for_status()
search = r.json()
if 'topics' not in search or not search['topics']:
raise Exception(f"No topic found for \"{frontmatter['title']}\"")
result = search['topics'][0]
frontmatter["redirect_to"] = f"{BASEURL}/t/{result['slug']}/{result['id']}"
with open(path, "w") as f:
f.write("---\n")
f.write(yaml.dump(frontmatter))
f.write("---\n")
if __name__ == "__main__":
try:
main(sys.argv[1])
except Exception as e:
print(f"{sys.argv[1]}: {e!s}")
```
And called this way:
find external/ -type f -exec update-community-redirect {} \;
Not all pages were found:
external/building-guides/building-archlinux-template.md: No topic found for "Building Arch Linux template"
external/building-guides/building-non-fedora-template.md: No topic found for "Building non-Fedora template"
external/configuration-guides/multimedia.md: No topic found for "How to make a multimedia template"
external/configuration-guides/tips-and-tricks.md: No topic found for "Tips and tricks"
external/customization-guides/fedora-minimal-template-customization.md: No topic found for "Fedora minimal template customization"
external/customization-guides/removing-templatevm-packages.md: No topic found for "Removing template packages"
external/customization-guides/windows-template-customization.md: No topic found for "Windows template customization"
external/os-guides/netbsd.md: No topic found for "How to create a NetBSD qube"
external/os-guides/pentesting/blackarch.md: No topic found for "How to create a BlackArch qube"
external/os-guides/pentesting/kali.md: No topic found for "How to create a Kali Linux qube"
external/os-guides/pentesting/ptf.md: No topic found for "How to create penetration testers framework (PTF) qube"
external/privacy-guides/tails.md: No topic found for "Running Tails in qubes"
external/security-guides/multifactor-authentication.md: No topic found for "Multifactor authentication"
external/troubleshooting/sony-vaio-tinkering.md: No topic found for "Sony Vaio tinkering"