Giter Club home page Giter Club logo

Comments (17)

Nikoos avatar Nikoos commented on August 15, 2024 3

I had the same issue as you, however after doing some research on Internet, I was able to run a static site generation with the following command:

gssg --domain "https://localhost:8080" --url "http://192.168.57.221:8081" --dest docs

I found this command here : https://dev.to/eli_xciv/from-ghost-blog-to-static-site-pke.

Nikos

from ghost-static-site-generator.

dmd avatar dmd commented on August 15, 2024 2

Another workaround is to modify your /etc/hosts file

Now I'm just a humble chicken farmer but I'd suggest that having localhost point anywhere other than localhost is a supremely bad idea and likely to break all sorts of things.

from ghost-static-site-generator.

imtomjorge avatar imtomjorge commented on August 15, 2024 1

The issue also persists on Debian Buster:

root@ghost-static:~# lsb_release -d
Description:	Debian GNU/Linux 11 (bullseye)
root@ghost-static:~# gssg --version
1.1.4

from ghost-static-site-generator.

mewmix avatar mewmix commented on August 15, 2024 1

Same issue on WSL 2 ! No issues on my Mac tho?

from ghost-static-site-generator.

theyij avatar theyij commented on August 15, 2024 1

Having the same issue here, tried the following command but did not work.
$ gssg ---domain "https://localhost:2368" --url "https://mysite.com"

Does editing config.development.json file help?

from ghost-static-site-generator.

shafqatalix avatar shafqatalix commented on August 15, 2024

any update, i am facing same issue on fedora?

from ghost-static-site-generator.

rmarchant avatar rmarchant commented on August 15, 2024

As a workound, I just manually update the /usr/lib/node_modules/ghost-static-site-generator/src/constants/OPTIONS.js file, and replace the lines that reference localhost:2368 with the desired hostname:port.

from ghost-static-site-generator.

ItsIgnacioPortal avatar ItsIgnacioPortal commented on August 15, 2024

Another workaround is to temporarily* modify your /etc/hosts file

from ghost-static-site-generator.

ItsIgnacioPortal avatar ItsIgnacioPortal commented on August 15, 2024

Another workaround is to modify your /etc/hosts file

Now I'm just a humble chicken farmer but I'd suggest that having localhost point anywhere other than localhost is a supremely bad idea and likely to break all sorts of things.

Obviously you shouldn't keep this modification forever. Just modify it before running gssg, and restore it afterwards hahah

it worked for me

from ghost-static-site-generator.

wegotoeleven avatar wegotoeleven commented on August 15, 2024

+1, same issue on Alpine

from ghost-static-site-generator.

wunderhund avatar wunderhund commented on August 15, 2024

Seeing a similar issue when running in a node:14 docker container. When I run Nikos' command above and point gssg to a ghost host other than localhost, certain files are still requested from localhost. In this case the container is connected to a docker network where it can reach ghost at http://ghost:2368:

root@700458ead844:/app# gssg --domain "http://ghost:2368" --url "http://blog.craigabutler.com" --ignore-absolute-paths
Fetching: http://ghost:2368/
index.html                            100%[======================================================================>]  32.98K  --.-KB/s    in 0.005s
robots.txt                            100%[======================================================================>]     107  --.-KB/s    in 0s
assets/built/screen.css?v=2124e23fcd  100%[======================================================================>]  41.63K  --.-KB/s    in 0.005s
public/cards.min.js?v=2124e23fcd      100%[======================================================================>]   7.23K  --.-KB/s    in 0s
public/cards.min.css?v=2124e23fcd     100%[======================================================================>]  25.48K  --.-KB/s    in 0.004s
test-post/index.html                  100%[======================================================================>]  13.74K  --.-KB/s    in 0.001s

[ ... ]

Fetching: http://ghost:2368/sitemap.xsl
sitemap.xsl                           100%[======================================================================>]   6.39K  --.-KB/s    in 0s
Fetching: http://ghost:2368/sitemap.xml
sitemap.xml                           100%[======================================================================>]     638  --.-KB/s    in 0s
Fetching: http://localhost:2368/sitemap-pages.xml
ERROR: null
Using Command: wget -q --show-progress --recursive --timestamping --page-requisites --no-parent --no-host-directories --restrict-file-name=unix --directory-prefix static --content-on-error  --trust-server-names http://localhost:2368/sitemap-pages.xml
statichttp://localhost:2368/sitemap-pages.xml http://localhost:2368/sitemap-pages.xml Error: ENOENT: no such file or directory, open '/app/statichttp:/localhost:2368/sitemap-pages.xml'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at fetchUrlHelper (/usr/local/lib/node_modules/ghost-static-site-generator/src/helpers/fetchUrlHelper/fetchUrlHelper.js:47:31)
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/ghost-static-site-generator/src/helpers/fetchUrlHelper/fetchUrlHelper.js:56:11
    at Parser.<anonymous> (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/xml2js/lib/parser.js:304:18)
    at Parser.emit (events.js:400:28)
    at SAXParser.onclosetag (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/xml2js/lib/parser.js:262:26)
    at emit (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/sax/lib/sax.js:629:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/app/statichttp:/localhost:2368/sitemap-pages.xml'
}

The affected files are:

  • sitemap-pages.xml
  • sitemap-posts.xml
  • sitemap-authors.xml
  • sitemap-tags.xml

I haven't figured out what the problem is, but the fact that they're all XML files makes me think that it's some kind of issue in replaceXmlUrlsHelper where OPTIONS.SOURCE_DOMAIN_WITHOUT_PROTOCOL is loading the default 'localhost' value instead of whatever was passed into the --domain option.

To address @imtomjorge's original post, looking at the commit history, I see that the --sourceDomain option was added in 2d8bfd8, after the 1.1.4 release. In fact, GitHub thinks that the current version in the repository is 1.2.0, but the version provided by npm is still 1.1.4. @fried-chicken is there any reason you haven't pushed the newer version to npm?

from ghost-static-site-generator.

Nikoos avatar Nikoos commented on August 15, 2024

@wunderhund you're correct, I remember using npm instead of sources from this repo, sorry for the trouble.

from ghost-static-site-generator.

ItsIgnacioPortal avatar ItsIgnacioPortal commented on August 15, 2024

Seeing a similar issue when running in a node:14 docker container. When I run Nikos' command above and point gssg to a ghost host other than localhost, certain files are still requested from localhost. In this case the container is connected to a docker network where it can reach ghost at http://ghost:2368:

root@700458ead844:/app# gssg --domain "http://ghost:2368" --url "http://blog.craigabutler.com" --ignore-absolute-paths
Fetching: http://ghost:2368/
index.html                            100%[======================================================================>]  32.98K  --.-KB/s    in 0.005s
robots.txt                            100%[======================================================================>]     107  --.-KB/s    in 0s
assets/built/screen.css?v=2124e23fcd  100%[======================================================================>]  41.63K  --.-KB/s    in 0.005s
public/cards.min.js?v=2124e23fcd      100%[======================================================================>]   7.23K  --.-KB/s    in 0s
public/cards.min.css?v=2124e23fcd     100%[======================================================================>]  25.48K  --.-KB/s    in 0.004s
test-post/index.html                  100%[======================================================================>]  13.74K  --.-KB/s    in 0.001s

[ ... ]

Fetching: http://ghost:2368/sitemap.xsl
sitemap.xsl                           100%[======================================================================>]   6.39K  --.-KB/s    in 0s
Fetching: http://ghost:2368/sitemap.xml
sitemap.xml                           100%[======================================================================>]     638  --.-KB/s    in 0s
Fetching: http://localhost:2368/sitemap-pages.xml
ERROR: null
Using Command: wget -q --show-progress --recursive --timestamping --page-requisites --no-parent --no-host-directories --restrict-file-name=unix --directory-prefix static --content-on-error  --trust-server-names http://localhost:2368/sitemap-pages.xml
statichttp://localhost:2368/sitemap-pages.xml http://localhost:2368/sitemap-pages.xml Error: ENOENT: no such file or directory, open '/app/statichttp:/localhost:2368/sitemap-pages.xml'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at fetchUrlHelper (/usr/local/lib/node_modules/ghost-static-site-generator/src/helpers/fetchUrlHelper/fetchUrlHelper.js:47:31)
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/ghost-static-site-generator/src/helpers/fetchUrlHelper/fetchUrlHelper.js:56:11
    at Parser.<anonymous> (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/xml2js/lib/parser.js:304:18)
    at Parser.emit (events.js:400:28)
    at SAXParser.onclosetag (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/xml2js/lib/parser.js:262:26)
    at emit (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/usr/local/lib/node_modules/ghost-static-site-generator/node_modules/sax/lib/sax.js:629:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/app/statichttp:/localhost:2368/sitemap-pages.xml'
}

The affected files are:

* sitemap-pages.xml

* sitemap-posts.xml

* sitemap-authors.xml

* sitemap-tags.xml

I haven't figured out what the problem is, but the fact that they're all XML files makes me think that it's some kind of issue in replaceXmlUrlsHelper where OPTIONS.SOURCE_DOMAIN_WITHOUT_PROTOCOL is loading the default 'localhost' value instead of whatever was passed into the --domain option.

To address @imtomjorge's original post, looking at the commit history, I see that the --sourceDomain option was added in 2d8bfd8, after the 1.1.4 release. In fact, GitHub thinks that the current version in the repository is 1.2.0, but the version provided by npm is still 1.1.4. @fried-chicken is there any reason you haven't pushed the newer version to npm?

have a look at #61, there's a couple of handy scripts there

from ghost-static-site-generator.

ItsIgnacioPortal avatar ItsIgnacioPortal commented on August 15, 2024

I've fixed this bug in my fork of ghost-static-site-generator! https://github.com/itsignacioportal/ghost-static-site-generator/

from ghost-static-site-generator.

rija avatar rija commented on August 15, 2024

Hi @wunderhund,

I'm using Docker and I have met the same issue as you when running my gssg container service with

command: /usr/local/bin/gssg --domain "http://ghost:2368" --dest "/var/www/public" --url $REMOTE_URL

I've almost fixed the problem by aliasing the ghost container service as localhost.
This is done by giving it a fixed IP address and then defining an extra_hosts section in the gssg container service:

extra_hosts:
    - "localhost:172.31.238.10"

The only problem left is the domain won't be replaced with the remote url for the Sitemap files. This was fixed by dropping --domain altogether and letting gssg thinks it's interacting with localhost for all files. After that, it all worked for me with the version of gssg available on NPM. Below is the full docker-compose.yml file (I have a separate .env file to define the environment variables):

version: '3.7'

services:
  ghost:
    image: ghost:4.48.8-alpine
    volumes:
      - ./content:/var/lib/ghost/content
      - ./config.production.json:/var/lib/ghost/config.production.json
    ports:
      - 2368:2368
    networks:
      app-net:
        ipv4_address: 172.31.238.10

  gssg:
    build: .
    volumes:
      - "./static:/var/www"
    command: /usr/local/bin/gssg --dest "/var/www/public" --url $REMOTE_URL
    extra_hosts:
      - "localhost:172.31.238.10"
    networks:
      - app-net

networks:
  app-net:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.31.238.0/24

The Dockerfile used by the gssg container service is quite simple:

FROM node:19-alpine

RUN apk add --no-cache npm wget && \
	npm i -g ghost-static-site-generator

Usage:

$ docker-compose build gssg
$ docker-compose up -d ghost
$ docker-compose run --rm gssg

from ghost-static-site-generator.

Stunt0265 avatar Stunt0265 commented on August 15, 2024

Was this ever resolved? Happening to me on Ubuntu 20.04. Should I be able to install 1.2 using this command?

sudo npm install -g https://github.com/Fried-Chicken/ghost-static-site-generator.git

from ghost-static-site-generator.

ItsIgnacioPortal avatar ItsIgnacioPortal commented on August 15, 2024

Was this ever resolved? Happening to me on Ubuntu 20.04. Should I be able to install 1.2 using this command?

sudo npm install -g Fried-Chicken/ghost-static-site-generator.git

Look at #72
https://github.com/ItsIgnacioPortal/ghost-static-site-generator/tree/master

from ghost-static-site-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.