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

Wrong URLs in Generated Files #4

Closed
vermont42 opened this Issue Jan 12, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@vermont42
Copy link
Owner

vermont42 commented Jan 12, 2019

This blog has RSS enabled. In my RSS reader, until I implemented a workaround today, the post URLs in my RSS feed were incorrect. Here is an example URL I saw in my feed reader: http://localhost:4000/blog/more-reviews/ The URL should have been http://racecondition.software/blog/more-reviews/.

I don't know much about RSS, but I suspect that the problem was that the feed.xml that Jekyll generated had localhost:4000 rather than racecondition.software. My defective feed.xml is excerpted below. FWIW, my feed.json, robots.txt, and various html files also had localhost:4000 rather than racecondition.software.

As a temporary workaround, I ran the following commands today before uploading to S3. This fixed the problem, but I would be grateful if @jessesquires could provide insight as to how to get Jekyll to put the correct URLs in files.

Workaround

find . -type f -name '*.html' -exec sed -i '' s/localhost:4000/racecondition.software/ {} +
find . -type f -name '*.xml' -exec sed -i '' s/localhost:4000/racecondition.software/ {} +
find . -type f -name '*.json' -exec sed -i '' s/localhost:4000/racecondition.software/ {} +
find . -type f -name '*.txt' -exec sed -i '' s/localhost:4000/racecondition.software/ {} +

feed.xml Excerpt

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Race Condition</title>
    <subtitle>A Blog by Josh Adams</subtitle>
    <link href="http://localhost:4000/feed.xml" rel="self" />
    <link href="http://localhost:4000" />
    <updated>2019-01-11T12:35:45-08:00</updated>
    <id>http://localhost:4000</id>

    <author>
        <name>Josh Adams</name>
    </author>

    <icon>http://localhost:4000/ico/logo.png</icon>

    <category term="programming"/>
    <category term="ios"/>
    <category term="swift"/>
    <category term="objective-c"/>
    <category term="software"/>
    <category term="mobile"/>

    <entry>
        <link href="http://localhost:4000/blog/more-reviews/" />
        <id>http://localhost:4000/blog/more-reviews</id>
        <title>Ratings and Reviews</title>
        <subtitle>How to Get More of Them</subtitle>
        <published>2019-01-08T00:00:00-08:00</published>

        <updated>2019-01-08T00:00:00-08:00</updated>

        <summary><p>This blog post describes two techniques for getting more ratings and reviews.</p>
@jessesquires

This comment has been minimized.

Copy link
Contributor

jessesquires commented Jan 12, 2019

hey @vermont42 👋

Ok, so everything appears to be setup correctly.

The correct site.url is specified in your config:
https://github.com/vermont42/racecondition.software/blob/master/_config.yml#L21

And that's what's referenced in your feed.xml:
https://github.com/vermont42/racecondition.software/blob/master/feed.xml#L9


The question is, how are you deploying your site?

It looks like you are not using GitHub pages for hosting, correct?

It appears like your workflow is probably something like:

  1. write and build the site locally using bundle exec jekyll serve
  2. wherever you host, dump the contents of _site/ once you're ready.

This would cause the http://localhost:4000/ problem. You should just be running bundle exec jekyll build, then deploying. But before you do, you can check the contents of _site/ and see if everything is generated correctly.

Is that what's happening?


I'd recommend deploying via Git. I wrote about this here. There are lots of details that won't matter for you. The relevant parts are (1) hosting your git repo on your server, (2) setting up git hooks to run jekyll build and dump _site/ into your public www directory. Then you can git push to your server and everything should just work™️

Hope this helps! 😄

@vermont42

This comment has been minimized.

Copy link
Owner Author

vermont42 commented Jan 12, 2019

You are correct! I did not realize that bundle exec jekyll serve puts localhost in all the files, but in retrospect, that makes sense. How else could my browser see files in localhost? I need to just bundle exec jekyll build and then deploy to S3.

Much appreciated.

In future, I will deploy via Git hook.

@vermont42 vermont42 closed this Jan 12, 2019

@jessesquires

This comment has been minimized.

Copy link
Contributor

jessesquires commented Jan 13, 2019

Awesome! 👏 I'm glad it's fixed! 💪

Thanks for the kind words @vermont42 ! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment