Repository: getnikola/nikola

Issue:
Allow setting custom GUID in feeds
It should be possible to set the GUID in RSS feeds or ID in Atom feeds to a value set in the post metadata. This helps renaming pages or moving the whole site to a new domain without the posts showing up as new in feedreaders.

I've already implemented this and I will submit a pull request soon.

I'm not yet sure about a detail: What should be the default GUID of new posts? It could either be their URL as it always is at the moment or a random value could be written to the file.

Allow setting custom GUID in feeds
It should be possible to set the GUID in RSS feeds or ID in Atom feeds to a value set in the post metadata. This helps renaming pages or moving the whole site to a new domain without the posts showing up as new in feedreaders.

I've already implemented this and I will submit a pull request soon.

I'm not yet sure about a detail: What should be the default GUID of new posts? It could either be their URL as it always is at the moment or a random value could be written to the file.

[WIP] Optionally read rss guid from the post
I'm working on enhancing Nikola to support publishing a podcast RSS feed. Most of this work is going into a "postcast" plugin I'm working on, and will submit or publish eventually; but some of what I'm trying to do requires support in Nikola itself.

This PR aims to support optional explicit (and, thus, static) GUIDs from posts, so that if I move where the podcast posts are they don't flood podcast apps with old episodes.

> [Assign the GUID to an episode only once and never change it. Assigning new GUIDs to existing episodes can cause issues with your podcast’s listing and chart placement in the iTunes Store.](https://help.apple.com/itc/podcasts_connect/#/itcb54353390)

Other related PRs I'm working on:

* #2676 (copyright tag in rss feeds)
* #2674 (iTunes rss tags)

I'd also be interested in direction for where and how to publish a plugin, when that's ready.


Discussion:

Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -1728,7 +1728,7 @@ def generic_rss_renderer(self, lang, title, link, description, timeline, output_
                             post.date.astimezone(dateutil.tz.tzutc())),
                 'categories': post._tags.get(lang, []),
                 'creator': post.author(lang),
-                'guid': post.permalink(lang, absolute=True),
+                'guid': post.guid(lang),
             }
 
             if post.author(lang):
@@ -2397,7 +2397,7 @@ def atom_post_text(post, text):
             entry_title = lxml.etree.SubElement(entry_root, "title")
             entry_title.text = post.title(lang)
             entry_id = lxml.etree.SubElement(entry_root, "id")
-            entry_id.text = post.permalink(lang, absolute=True)
+            entry_id.text = post.guid(lang)
             entry_updated = lxml.etree.SubElement(entry_root, "updated")
             entry_updated.text = post.formatted_updated('webiso')
             entry_published = lxml.etree.SubElement(entry_root, "published")
diff --git a/nikola/post.py b/nikola/post.py
--- a/nikola/post.py
+++ b/nikola/post.py
@@ -405,6 +405,17 @@ def description(self, lang=None):
             lang = nikola.utils.LocaleBorg().current_lang
         return self.meta[lang]['description']
 
+    def guid(self, lang=None):
+        """Return localized GUID."""
+        if lang is None:
+            lang = nikola.utils.LocaleBorg().current_lang
+        if self.meta[lang]['guid']:
+            guid = self.meta[lang]['guid']
+        else:
+            guid = self.permalink(lang, absolute=True)
+
+        return guid
+
     def add_dependency(self, dependency, add='both', lang=None):
         """Add a file dependency for tasks using that post.
 


Test patch: