You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2026/04/15 21:00:41 UTC

(airflow-site) 01/01: Fix broken blog Atom feed (invalid XML) and use absolute URLs

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch fix-blog-atom-feed
in repository https://gitbox.apache.org/repos/asf/airflow-site.git

commit b93f9e25ee0d071ddf080f34c017d2a2ed9c8065
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Wed Apr 15 22:00:29 2026 +0100

    Fix broken blog Atom feed (invalid XML) and use absolute URLs
    
    The blog Atom feed has been broken since it was introduced in #1391.
    Three issues:
    
    1. Leading whitespace before the XML declaration — Hugo strips
       template comments but preserves surrounding newlines, producing
       blank lines before <?xml?> which must be at byte 0.
    
    2. HTML escaping of XML constructs — Hugo's html/template engine
       escaped <?xml to &lt;?xml and <![CDATA[ to &lt;![CDATA[. Pipe
       through safeHTML to emit raw XML.
    
    3. Relative URLs — the Atom spec requires absolute URIs in <link>
       and <id> elements. Since baseURL is "/", .Permalink produced
       paths like /blog/foo/. Added a canonicalBaseURL site param to
       prefix the canonical domain.
    
    Closes #1490
---
 landing-pages/site/config.toml           |  1 +
 landing-pages/site/layouts/blog/list.xml | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/landing-pages/site/config.toml b/landing-pages/site/config.toml
index eef3e0f1aa..8f2535c135 100644
--- a/landing-pages/site/config.toml
+++ b/landing-pages/site/config.toml
@@ -68,6 +68,7 @@ description = "Platform created by the community to programmatically author, sch
 # Everything below this are Site Params
 
 [params]
+canonicalBaseURL = "https://airflow.apache.org"
 charset = "utf-8"
 copyright = "The Apache Software Foundation"
 privacy_policy = "https://policies.google.com/privacy"
diff --git a/landing-pages/site/layouts/blog/list.xml b/landing-pages/site/layouts/blog/list.xml
index 2675e0d79e..f275455f68 100644
--- a/landing-pages/site/layouts/blog/list.xml
+++ b/landing-pages/site/layouts/blog/list.xml
@@ -1,4 +1,4 @@
-{{/*
+{{- /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
@@ -15,14 +15,14 @@
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-*/}}
-
-<?xml version="1.0" encoding="utf-8"?>
+*/ -}}
+{{- $base := .Site.Params.canonicalBaseURL | default "" -}}
+{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }}
 <feed xmlns="http://www.w3.org/2005/Atom">
   <title>{{ .Site.Title }} Blog</title>
-  <link href="{{ .Permalink }}" rel="alternate"/>
-<link href="{{ .Permalink }}index.xml" rel="self" type="application/atom+xml"/>
-<id>{{ .Permalink }}</id>
+  <link href="{{ $base }}{{ .Permalink }}" rel="alternate"/>
+  <link href="{{ $base }}{{ .Permalink }}index.xml" rel="self" type="application/atom+xml"/>
+  <id>{{ $base }}{{ .Permalink }}</id>
 {{ $pages := sort .Pages "Lastmod" "desc" }}
 {{ with index $pages 0 }}
   <updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z" }}</updated>
@@ -30,14 +30,14 @@
 {{ range sort .Pages "Lastmod" "desc" }}
   <entry>
     <title>{{ .Title }}</title>
-    <link href="{{ .Permalink }}" rel="alternate"/>
-    <id>{{ .Permalink }}</id>
+    <link href="{{ $base }}{{ .Permalink }}" rel="alternate"/>
+    <id>{{ $base }}{{ .Permalink }}</id>
     <published>{{ .PublishDate.Format "2006-01-02T15:04:05Z" }}</published>
     <updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z" }}</updated>
     <author>
       <name>Apache Airflow</name>
     </author>
-    <content type="html"><![CDATA[{{ .Content }}]]></content>
+    <content type="html">{{ printf "<![CDATA[%s]]>" .Content | safeHTML }}</content>
   </entry>
   {{ end }}
 </feed>