Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match output paths with content paths #2673

Closed
ghost opened this issue Dec 28, 2019 · 5 comments
Closed

Match output paths with content paths #2673

ghost opened this issue Dec 28, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Dec 28, 2019

I have this setup:

content/number-types/index.rst

and I expect this result:

content/number-types/index.html

However I am not sure how to make that happen. First I set this:

# pelicanconf.py
SLUGIFY_SOURCE = 'basename'

and I get this result:

CRITICAL: RuntimeError: File /tmp/output/index.html is to be overwritten

So I change to this setup:

content/number-types/readme.rst

and get this result:

output/readme.html

so then I try this:

SLUGIFY_SOURCE = 'basename'
ARTICLE_SAVE_AS = '{slug}/index.html'

and get this result:

output/readme/index.html

How can I get Pelican to stop trying to be smart, and just replicate the paths
as I have them?

@justinmayer
Copy link
Member

If you remove the settings file changes mentioned above and instead add the following…

# Mirror content hierarchy to output hierarchy
PATH_METADATA= '(?P<path_no_ext>.*)\..*'
ARTICLE_SAVE_AS= '{path_no_ext}.html'
ARTICLE_URL= '{path_no_ext}.html'
PAGE_SAVE_AS= '{path_no_ext}.html'
PAGE_URL= '{path_no_ext}.html'

… does that result in the output you expect?

@ghost
Copy link
Author

ghost commented Dec 28, 2019

@justinmayer yes, looks like it works with just this:

PATH_METADATA= '(?P<path_no_ext>.*)\..*'
ARTICLE_SAVE_AS = '{path_no_ext}.html'
ARTICLE_URL = '{path_no_ext}.html'

@justinmayer
Copy link
Member

@cup: Yes, but the PAGE_* settings are needed if one were to want the same behavior for pages.

@justinmayer
Copy link
Member

Duplicate of #686. Since the answer should be more visible, I documented the aforementioned solution via b8f2326.

@cup: Rather than submitting a flurry of short-lived issues as questions arise, which results in extra noise for maintainers, in the future please consider reaching out via the Pelican IRC channel, as noted in the How to Get Help section of the documentation. Thanks!

@ghost
Copy link
Author

ghost commented Dec 28, 2019

@justinmayer I came up with this one - removes extra part from the URL:

PATH_METADATA = '(?P<dirname>.*)/(?P<basename>.*)\..*'
ARTICLE_SAVE_AS = '{dirname}/{basename}.html'
ARTICLE_URL = '{dirname}'

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

No branches or pull requests

1 participant