Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Override page 'url' and 'save_as' directly from the page metadata #623

Merged
merged 3 commits into from Mar 4, 2013

Conversation

Projects
None yet
6 participants
Contributor

bbinet commented Dec 6, 2012

In some cases, we'd like to be able to output a specific article or page to a different url that the one which is specified in the ARTICLE_URL/ARTICLE_SAVE_AS or PAGE_URL/PAGE_SAVE_AS setting.

One typical use case is the ability to set a specific page as index instead of the articles list, so this will address #400.

bbinet added some commits Dec 6, 2012

allow override page url and save_as values directly from the metadata
this is similar to the template override implemented in #404
add functional test for save_as/url override
and update functional tests output
Contributor

bbinet commented Dec 6, 2012

Docs are still missing in this pr.

Contributor

bbinet commented Dec 6, 2012

I've also seen that @michaelreneer had asked for this feature on irc tonight. Here is his use case:
"""
I have 2 pages "About" and "404". I want the "About" page to be saved to '{slug}/index.html' and I want the "404" page to be saved to '{slug}.html' any ideas?
I have two ways to do it, one really dirty way... set the about page slug = "about/index" and the 404 slug = "404 and set the PAGE_SAVE_AS = '{slug}.html
this works but is really shady
second way is to make a template outside of the theme and use TEMPLATE_PAGES to create the 404 instead of making it as a page + status: hidden, but I would rather not put
content in a template (even if the template is not in the theme)
and even if its only one line of content
I wonder if anyone else would find a page level override for the PAGE_SAVE_AS setting useful (similar to the TEMPLATE override)?
"""

@justinmayer justinmayer referenced this pull request Dec 6, 2012

Closed

status:draft for pages #456

Contributor

bbinet commented Dec 7, 2012

Now with some documentation: 802c9d1.

Contributor

elemoine commented Jan 1, 2013

I'd like my site's main page (/index.html) to not list articles, but to include an aboutme page instead. This pull request seems to cover my use-case.

I use INDEX_SAVE_AS = blog.html for the notmyidea index.html template to be saved as blog.html in the output dir. But I'd need to add a "Blog" item linking to blog.html to the menu, and I don't know how to achieve that. I'd also like not to have the categories in the menu, which, it seems, is covered by #578.

All this sounds over-complex to me. The notmyidea theme lists the articles on the index/front page, making it work otherwise through config options sounds like abusing the theme to me.

Owner

almet commented Jan 1, 2013

@elemoine I'm not sure to understand what you want to say with your previous message.

Is there a problem? Are you suggesting to fix things differently?

Contributor

elemoine commented Jan 1, 2013

Sorry for being unclear. I think this pull request does provide a relevant feature. I'm just saying that having many _SAVE_AS settings may be the sign of me abusing the notmyidea theme, and that it may be time to write my own, possible notmyidea-based, theme.

Owner

almet commented Jan 2, 2013

I completely agree, the themes are, or at least should be the main extension point of pelican

Contributor

elemoine commented Jan 2, 2013

Thanks for confirming. The docs say that the "simple" theme can be extended through inheritance. Wondering why this isn't the case for notmyidea, and other themes. I'll investigate. Thanks again.

Contributor

wking commented Jan 16, 2013

This relates to my work in #671 on EXTRA_PAGE_METADATA in #671. See 43b10c3 and 518a3da.

Contributor

erichgoldman commented Jan 30, 2013

This sounds useful, but if you just want to change the content of the index page, you can just edit the content block, though I don't believe there is a way right now to slip in a specific article, maybe if you import the a page specific template?

Owner

justinmayer commented Feb 10, 2013

@bbinet / @ametaireau: This seems to allow people to use an arbitrary page as their home page, which many folks have requested. Docs are there, tests are passing. Any reason not to merge now?

Contributor

bbinet commented Feb 11, 2013

I'm the one who submitted ths PR, so I'm of course +1 to merge :-) This was just waiting for a review from somebody else.

Owner

justinmayer commented Feb 24, 2013

Works very well in my testing. Nice job, Bruno! 😄

The only minor hiccup, and it's by no means a blocker, is when I change the metadata in the samples/content/pages/override_url_saveas.rst file to:

:url: /
:save_as: index.html

... the URL in the top nav for Home is: http://localhost:8000// (note the extra slash)

As a workaround, when I set the metadata to:

:url: 
:save_as: index.html

... then the URL appears as I expect: http://localhost:8000/

When I tested on my own site content, which uses "clean" URLs, I did not experience the double-slash and did not need the above workaround.

Like I said, I don't consider this to be a blocker. Just thought I'd pass along the results of my testing.

Owner

justinmayer commented Mar 4, 2013

As noted previously, I've tested this feature and have found it functions according to expectations. Given that this feature is requested on a near-daily basis, it seems it will help a great many folks. Merging.

justinmayer added a commit that referenced this pull request Mar 4, 2013

Merge pull request #623 from bbinet/url-save_as-override
Override page 'url' and 'save_as' directly from the page metadata. Fixes #400.

@justinmayer justinmayer merged commit d0e9c52 into getpelican:master Mar 4, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment