Adding PDFs to Hugo sitemap

I want my website to be indexed by Google, but I’m running into a few issues.

  1. First, I cannot seem to get Google Search Console to read my sitemap.


    The XML should be valid, and I’ve had no issue with Bing’s indexing. My website is on Github Pages. I found this and this, but these weren’t helpful in resolving my issue.

  2. My website contains a number of PDFs. Some are under the static directory, while others are in a page bundles. I’m currently using the default sitemap.xml template, but I understand how to override it.

content
└── projects
    ├── papers
    │   ├── Final Report.pdf
    │   └── Data Analysis.pdf
    └── index.md

How can I include the PDFs from these page bundles in my sitemap automatically?

nothing for 1)

you already have a layouts\_default\sitemap.xml in

  • for each reported page scan for resources incl. subfolders.
  • adjust the output and/or add filters for which page you want that.
  ...
  {{ range where .Pages "Sitemap.Disable" "ne" true }}
    {{- if .Permalink -}}
      {{ if not (strings.Contains .RelPermalink "/tags") }}
  <url>
    ...
  </url>
      {{ range .Resources.Match "**/*.pdf"}}
         <url>{{ .RelPermalink }}</url>         {{/* adjust here */}}
      {{ end }}
   ...