Skip to content

Conversation

jwise
Copy link

@jwise jwise commented Sep 21, 2025

Pull Request Checklist

  • I’ve read the guidelines for contributing.
  • I updated AUTHORS.txt and CHANGES.txt (if the change is non-trivial) and documentation (if applicable).
  • I tested my changes.

Description

Implements #3862 with a tag external_url to represent "metadata-only entries".

I've tried to follow the CONTRIBUTING.rst guidelines for this, but please let me know if I screwed something up! This, at least, passes pytest, and works in my test site.

Fix getnikola#3862.

Signed-off-by: Joshua Wise <joshua@joshuawise.com>
@jwise
Copy link
Author

jwise commented Sep 21, 2025

Argh, of course, this almost worked, up until I added a new file that previously didn't exist as a cached item, and then I run into:

(venv) joshua@anima:~/work/joshuaweb-next$ nikola build
Scanning posts........done!
.  render_posts:timeline_changes
.  render_taxonomies:output/categories/external/index.html
DependencyError - taskid:render_taxonomies:output/categories/external/index.html
ERROR: Task 'render_taxonomies:output/categories/external/index.html' saving success: Dependent file 'cache/posts/external/yogurt.html' does not exist.

########################################
render_taxonomies:output/categories/external/index.html <stdout>:

So that'll probably require at least one more task to generate. I'm tired and I'll figure that out tomorrow :)

@jwise
Copy link
Author

jwise commented Sep 21, 2025

Hm, I looked at this and I am having a little bit of trouble figuring out how to wire up a compile-only task in this case. Extra frustrating is that I can work around it by running Nikola twice, which gives me not much incentive to fix it right :-)

Does anyone have any suggestions?

@Kwpolska
Copy link
Member

Requiring to run Nikola twice is not acceptable for a feature that would exist in Nikola core.

This feature may require more thought and development. Nikola is not really designed for posts that do not have a corresponding HTML file, so this feature breaks a lot of assumptions.

@jwise
Copy link
Author

jwise commented Sep 21, 2025

Requiring to run Nikola twice is not acceptable for a feature that would exist in Nikola core.

Yeah, obviously I would need to fix that before it is mergeable. If anyone has any suggestions on how I would very much appreciate it, though :)

This feature may require more thought and development. Nikola is not really designed for posts that do not have a corresponding HTML file, so this feature breaks a lot of assumptions.

I thought that too, but then I looked some more, and found that although it would certainly make for some UX strangeness with some themes (especially around 'previous post' and 'next post'), it might not be fatal for people who don't plan to use those links in themes. Are there other assumptions I'm missing?

The core idea here is basically to make the surgical change of moving a permalink elsewhere (non-Nikola-owned) -- with "if it breaks, you get to keep both pieces" consequences for a user who wants to do that.

@Kwpolska
Copy link
Member

I don’t think we should be adding new features that are easily breakable and not compatible with the default themes.

An easier approach might be to have a post with some content (that describes the linked page), but also make links in important places (e.g. feeds) go to the external location.

@jwise
Copy link
Author

jwise commented Sep 21, 2025

Ok, this is a really important use case for me, and I would really like to not have to maintain a private fork that holds just one patch, so I would definitely like to figure out how we can make this mergeable :)

I definitely do not want to generate a post of any kind at all in the target output or in the sitemap, though I'm OK having one appear in the cache/ directory. How about if I changed the next_post and prev_post generator to skip over things with external_urls?

@ralsina
Copy link
Member

ralsina commented Sep 22, 2025 via email

@ralsina
Copy link
Member

ralsina commented Sep 22, 2025 via email

@jwise
Copy link
Author

jwise commented Sep 22, 2025

If what you want is so that some specific posts are not ever generated in the site but are generated in the RSS feeds, you can implement a plugin that overloads the RSS generation and adds more stuff in it.

The thing I'm really looking for in this case is that I want page lists and tag lists to include other things that don't exist inside the Nikola world. For instance, here are some files that I have created that use this feature:

joshua@anima:~/work/joshuaweb-next/posts/external$ cat 2015-in-music.md
<!--
.. title: 2015 in music
.. date: 2016-01-06 22:48:00 UTC-04:00
.. tags: external, dreamwidth, music
.. category: 
.. external_url: https://joshua0.dreamwidth.org/60622.html
.. description:
-->
joshua@anima:~/work/joshuaweb-next/posts/external$ cat 2016-in-music.md 
<!--
.. title: 2016 in music
.. date: 2017-01-10 23:17:00 UTC-04:00
.. tags: external, dreamwidth, music
.. category: 
.. external_url: https://joshua0.dreamwidth.org/62706.html
.. description:
-->
joshua@anima:~/work/joshuaweb-next/posts/external$ cat eoy2018.md 
<!--
.. title: on the horizon: 2018, as heard by Joshua.
.. date: 2018-12-31 00:25:00 UTC-04:00
.. tags: external, music, yearmix
.. category: 
.. external_url: https://joshuawise.com/resources/eoy2018/v1/
.. description:
-->
joshua@anima:~/work/joshuaweb-next/posts/external$ cat eoy2019.md 
<!--
.. title: on the edge: 2019, as heard by Joshua.
.. date: 2019-12-31 15:10:00 UTC-04:00
.. tags: external, music, yearmix
.. category: 
.. external_url: https://joshuawise.com/resources/eoy2019/v1/
.. description:
-->

These are basically stubs, but it is important to me that they all show show up in /categories/music/index.html, along with any other music-related things that I write inside of Nikola.

Similarly, I also used a custom post-list to render some of my favorite things I've put together as a list my home page. The example, for instance:

joshua@anima:~/work/joshuaweb-next$ cat posts/external/near-miss-data-loss.md
<!--
.. title: A near-miss data loss event
.. date: 2012-02-03 04:06:44 UTC-04:00
.. tags: favorites, external, dreamwidth
.. category: 
.. external_url: https://joshua0.dreamwidth.org/25045.html
.. why-favorite: or, how I accidentally paved over a machine
.. description:
-->

Is rendered by a custom post-list:

Here are some favorites and/or classics.

{{% post-list post_type=all tags=favorites template=favorites.tmpl %}}{{% /post-list %}}

Which uses the following in its guts:

        % for post in posts:
            <li class="post-list-item">
            ${post.formatted_date("MMMM yyyy")|h}
            &nbsp;
            <a href="${post.permalink(lang)}">${post.title(lang)|h}</a>
            %if post.meta('why-favorite'):
            -- ${post.meta('why-favorite')|h}
            %endif
            </li>
        % endfor

Does this make somewhat more sense in what I am trying to achieve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants