import_jekyll: Only set 'url' if 'permalink' in metadata & remove duplicate confirm msg #4257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When importing from Jekyll, Hugo adds the
url
attribute to the frontmatter for all posts and assumes that the final desired permalink structure is/:year/:month/:day/:title/
.This may be the case for a lot of peeps, but poses a problem for those that don't use this permalink structure as the
url
attribute takes precedence over thepermalink
attribute in the site-wide configuration meaning it can't be overruled.This PR resolves this by only setting the
url
attribute if thepermalink
attribute is set in the Jekyll frontmatter.Tests have been updated to reflect this change in behaviour too.
Whilst I'm at it, I've also removed the duplication of the confirmation message:
Before:
After:
Fixes #1887
PS. This my first Hugo (and Go) PR. Go easy on me 😉